Debian Codegraph @

plugins/functions/time.c

raw symbols SCIP
1 /*
2 Copyright (C) 2016-2018 Brazil
3 Copyright (C) 2021-2022 Sutou Kouhei <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifdef GRN_EMBEDDED
21 # define GRN_PLUGIN_FUNCTION_TAG functions_time
22 #endif /* GRN_EMBEDDED */
23
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif /* HAVE_CONFIG_H */
27
28 #include <groonga/plugin.h>
29
30 #include <math.h>
31 #include <stdlib.h>
32 #include <time.h>
33
34 #ifdef WIN32
35 # define timegm _mkgmtime
36 # define HAVE_TIMEGM
37 #else /* WIN32 */
38 # define HAVE_TIMEGM
39 #endif /* WIN32 */
40
41 typedef enum {
42 GRN_TIME_CLASSIFY_UNIT_SECOND,
43 GRN_TIME_CLASSIFY_UNIT_MINUTE,
44 GRN_TIME_CLASSIFY_UNIT_HOUR,
45 GRN_TIME_CLASSIFY_UNIT_DAY,
46 GRN_TIME_CLASSIFY_UNIT_WEEK,
47 GRN_TIME_CLASSIFY_UNIT_MONTH,
48 GRN_TIME_CLASSIFY_UNIT_YEAR
49 } grn_time_classify_unit;
50
51 static bool
52 func_time_classify_raw_compute(grn_ctx *ctx,
53 grn_obj *time,
54 grn_time_classify_unit unit,
55 uint32_t interval_raw,
56 int64_t *classed_time_raw,
57 const char *function_name)
58 {
59 int64_t time_raw;
60 struct tm tm;
61
62 if (time->header.domain != GRN_DB_TIME) {
63 grn_obj inspected;
64
65 GRN_TEXT_INIT(&inspected, 0);
66 grn_inspect(ctx, &inspected, time);
67 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
68 "%s(): "
69 "the first argument must be a time: "
70 "<%.*s>",
71 function_name,
72 (int)GRN_TEXT_LEN(&inspected),
73 GRN_TEXT_VALUE(&inspected));
74 GRN_OBJ_FIN(ctx, &inspected);
75 return false;
76 }
77
78 time_raw = GRN_TIME_VALUE(time);
79 if (!grn_time_to_tm(ctx, time_raw, &tm)) {
80 return false;
81 }
82
83 struct tm tm_timezone_offset;
84 grn_time_to_tm(ctx, 0, &tm_timezone_offset);
85 int64_t timezone_offset = 0;
86
87 switch (unit) {
88 case GRN_TIME_CLASSIFY_UNIT_SECOND :
89 tm.tm_sec = (tm.tm_sec / (int)interval_raw) * (int)interval_raw;
90 break;
91 case GRN_TIME_CLASSIFY_UNIT_MINUTE :
92 tm.tm_min = (tm.tm_min / (int)interval_raw) * (int)interval_raw;
93 tm.tm_sec = 0;
94 break;
95 case GRN_TIME_CLASSIFY_UNIT_HOUR :
96 tm.tm_hour = (tm.tm_hour / (int)interval_raw) * (int)interval_raw;
97 tm.tm_min = tm_timezone_offset.tm_min;
98 tm.tm_sec = 0;
99 timezone_offset = GRN_TIME_PACK((tm_timezone_offset.tm_min * 60),
100 0);
101 break;
102 case GRN_TIME_CLASSIFY_UNIT_DAY :
103 tm.tm_hour = tm_timezone_offset.tm_hour;
104 tm.tm_min = tm_timezone_offset.tm_min;
105 tm.tm_sec = 0;
106 timezone_offset = GRN_TIME_PACK((tm_timezone_offset.tm_hour * 60 * 60) +
107 (tm_timezone_offset.tm_min * 60),
108 0);
109 break;
110 case GRN_TIME_CLASSIFY_UNIT_WEEK :
111 if ((tm.tm_mday - tm.tm_wday) >= 0) {
112 tm.tm_mday -= tm.tm_wday;
113 } else {
114 int n_underflowed_mday = -(tm.tm_mday - tm.tm_wday);
115 int mday;
116 int max_mday = 31;
117
118 if (tm.tm_mon == 0) {
119 tm.tm_year--;
120 tm.tm_mon = 11;
121 } else {
122 tm.tm_mon--;
123 }
124
125 for (mday = max_mday; mday > n_underflowed_mday; mday--) {
126 int64_t unused;
127 tm.tm_mday = mday;
128 if (grn_time_from_tm(ctx, &unused, &tm)) {
129 break;
130 }
131 }
132 tm.tm_mday -= n_underflowed_mday;
133 }
134 tm.tm_hour = tm_timezone_offset.tm_hour;
135 tm.tm_min = tm_timezone_offset.tm_min;
136 tm.tm_sec = 0;
137 timezone_offset = GRN_TIME_PACK((tm_timezone_offset.tm_hour * 60 * 60) +
138 (tm_timezone_offset.tm_min * 60),
139 0);
140 break;
141 case GRN_TIME_CLASSIFY_UNIT_MONTH :
142 tm.tm_mon = (tm.tm_mon / (int)interval_raw) * (int)interval_raw;
143 tm.tm_mday = 1;
144 tm.tm_hour = tm_timezone_offset.tm_hour;
145 tm.tm_min = tm_timezone_offset.tm_min;
146 tm.tm_sec = 0;
147 timezone_offset = GRN_TIME_PACK((tm_timezone_offset.tm_hour * 60 * 60) +
148 (tm_timezone_offset.tm_min * 60),
149 0);
150 break;
151 case GRN_TIME_CLASSIFY_UNIT_YEAR :
152 tm.tm_year =
153 (((1900 + tm.tm_year) / (int)interval_raw) * (int)interval_raw) -
154 1900;
155 tm.tm_mon = 0;
156 tm.tm_mday = 1;
157 tm.tm_hour = tm_timezone_offset.tm_hour;
158 tm.tm_min = tm_timezone_offset.tm_min;
159 tm.tm_sec = 0;
160 timezone_offset = GRN_TIME_PACK((tm_timezone_offset.tm_hour * 60 * 60) +
161 (tm_timezone_offset.tm_min * 60),
162 0);
163 break;
164 }
165
166 if (!grn_time_from_tm(ctx, classed_time_raw, &tm)) {
167 return false;
168 }
169 *classed_time_raw -= timezone_offset;
170 return true;
171 }
172
173 static bool
174 func_time_classify_raw_validate_arg0(grn_ctx *ctx,
175 grn_obj *arg0,
176 const char *function_name)
177 {
178 if (arg0->header.domain == GRN_DB_TIME) {
179 switch (arg0->header.type) {
180 case GRN_BULK :
181 case GRN_UVECTOR :
182 return true;
183 default :
184 break;
185 }
186 }
187
188 grn_obj inspected;
189 GRN_TEXT_INIT(&inspected, 0);
190 grn_inspect(ctx, &inspected, arg0);
191 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
192 "%s(): "
193 "the first argument must be a time or a time vector: "
194 "<%.*s>",
195 function_name,
196 (int)GRN_TEXT_LEN(&inspected),
197 GRN_TEXT_VALUE(&inspected));
198 GRN_OBJ_FIN(ctx, &inspected);
199 return false;
200 }
201
202 static grn_obj *
203 func_time_classify_raw(grn_ctx *ctx,
204 int n_args,
205 grn_obj **args,
206 grn_user_data *user_data,
207 const char *function_name,
208 grn_time_classify_unit unit)
209 {
210 uint32_t interval_raw = 1;
211 bool accept_interval = true;
212
213 switch (unit) {
214 case GRN_TIME_CLASSIFY_UNIT_SECOND :
215 case GRN_TIME_CLASSIFY_UNIT_MINUTE :
216 case GRN_TIME_CLASSIFY_UNIT_HOUR :
217 accept_interval = true;
218 break;
219 case GRN_TIME_CLASSIFY_UNIT_DAY :
220 case GRN_TIME_CLASSIFY_UNIT_WEEK :
221 accept_interval = false;
222 break;
223 case GRN_TIME_CLASSIFY_UNIT_MONTH :
224 case GRN_TIME_CLASSIFY_UNIT_YEAR :
225 accept_interval = true;
226 break;
227 }
228
229 if (accept_interval) {
230 if (!(n_args == 1 || n_args == 2)) {
231 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
232 "%s(): "
233 "wrong number of arguments (%d for 1..2)",
234 function_name,
235 n_args);
236 return NULL;
237 }
238 } else {
239 if (n_args != 1) {
240 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
241 "%s(): "
242 "wrong number of arguments (%d for 1)",
243 function_name,
244 n_args);
245 return NULL;
246 }
247 }
248
249 grn_obj *arg0 = args[0];
250 if (!func_time_classify_raw_validate_arg0(ctx, arg0, function_name)) {
251 return NULL;
252 }
253
254 if (n_args == 2) {
255 grn_obj *interval;
256 grn_obj casted_interval;
257
258 interval = args[1];
259 if (!(interval->header.type == GRN_BULK &&
260 grn_type_id_is_number_family(ctx, interval->header.domain))) {
261 grn_obj inspected;
262
263 GRN_TEXT_INIT(&inspected, 0);
264 grn_inspect(ctx, &inspected, interval);
265 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
266 "%s(): "
267 "the second argument must be a number: "
268 "<%.*s>",
269 function_name,
270 (int)GRN_TEXT_LEN(&inspected),
271 GRN_TEXT_VALUE(&inspected));
272 GRN_OBJ_FIN(ctx, &inspected);
273 return NULL;
274 }
275
276 GRN_VALUE_FIX_SIZE_INIT(&casted_interval, 0, GRN_DB_UINT32);
277 grn_obj_cast(ctx, interval, &casted_interval, false);
278 interval_raw = GRN_UINT32_VALUE(&casted_interval);
279 GRN_OBJ_FIN(ctx, &casted_interval);
280
281 if (interval_raw == 0) {
282 grn_obj inspected;
283
284 GRN_TEXT_INIT(&inspected, 0);
285 grn_inspect(ctx, &inspected, interval);
286 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
287 "%s(): "
288 "the second argument must not be zero: "
289 "<%.*s>",
290 function_name,
291 (int)GRN_TEXT_LEN(&inspected),
292 GRN_TEXT_VALUE(&inspected));
293 GRN_OBJ_FIN(ctx, &inspected);
294 return NULL;
295 }
296 }
297
298 switch (arg0->header.type) {
299 case GRN_BULK :
300 {
301 grn_obj *time = arg0;
302 int64_t classed_time_raw;
303 bool success = func_time_classify_raw_compute(ctx,
304 time,
305 unit,
306 interval_raw,
307 &classed_time_raw,
308 function_name);
309 if (!success) {
310 return NULL;
311 }
312 grn_obj *classed_time = grn_plugin_proc_alloc(ctx,
313 user_data,
314 time->header.domain,
315 0);
316 if (!classed_time) {
317 return NULL;
318 }
319 GRN_TIME_SET(ctx, classed_time, classed_time_raw);
320
321 return classed_time;
322 }
323 break;
324 case GRN_UVECTOR :
325 if (arg0->header.domain == GRN_DB_TIME) {
326 grn_obj *times = arg0;
327 grn_obj *classed_times = grn_plugin_proc_alloc(ctx,
328 user_data,
329 times->header.domain,
330 GRN_OBJ_VECTOR);
331 if (!classed_times) {
332 return NULL;
333 }
334
335 {
336 size_t i;
337 size_t n_elements = GRN_TIME_VECTOR_SIZE(times);
338 grn_obj time;
339 GRN_TIME_INIT(&time, 0);
340 for (i = 0; i < n_elements; i++) {
341 GRN_BULK_REWIND(&time);
342 GRN_TIME_SET(ctx, &time, GRN_TIME_VALUE_AT(times, i));
343
344 int64_t classed_time_raw;
345 bool success = func_time_classify_raw_compute(ctx,
346 &time,
347 unit,
348 interval_raw,
349 &classed_time_raw,
350 function_name);
351 if (!success) {
352 GRN_OBJ_FIN(ctx, &time);
353 return NULL;
354 }
355
356 GRN_TIME_PUT(ctx, classed_times, classed_time_raw);
357 }
358 GRN_OBJ_FIN(ctx, &time);
359
360 return classed_times;
361 }
362 }
363 break;
364 }
365
366 return NULL;
367 }
368
369 static grn_obj *
370 func_time_classify_second(grn_ctx *ctx, int n_args, grn_obj **args,
371 grn_user_data *user_data)
372 {
373 return func_time_classify_raw(ctx,
374 n_args,
375 args,
376 user_data,
377 "time_classify_second",
378 GRN_TIME_CLASSIFY_UNIT_SECOND);
379 }
380
381 static grn_obj *
382 func_time_classify_minute(grn_ctx *ctx, int n_args, grn_obj **args,
383 grn_user_data *user_data)
384 {
385 return func_time_classify_raw(ctx,
386 n_args,
387 args,
388 user_data,
389 "time_classify_minute",
390 GRN_TIME_CLASSIFY_UNIT_MINUTE);
391 }
392
393 static grn_obj *
394 func_time_classify_hour(grn_ctx *ctx, int n_args, grn_obj **args,
395 grn_user_data *user_data)
396 {
397 return func_time_classify_raw(ctx,
398 n_args,
399 args,
400 user_data,
401 "time_classify_hour",
402 GRN_TIME_CLASSIFY_UNIT_HOUR);
403 }
404
405 static grn_obj *
406 func_time_classify_day(grn_ctx *ctx, int n_args, grn_obj **args,
407 grn_user_data *user_data)
408 {
409 return func_time_classify_raw(ctx,
410 n_args,
411 args,
412 user_data,
413 "time_classify_day",
414 GRN_TIME_CLASSIFY_UNIT_DAY);
415 }
416
417 static grn_obj *
418 func_time_classify_week(grn_ctx *ctx, int n_args, grn_obj **args,
419 grn_user_data *user_data)
420 {
421 return func_time_classify_raw(ctx,
422 n_args,
423 args,
424 user_data,
425 "time_classify_week",
426 GRN_TIME_CLASSIFY_UNIT_WEEK);
427 }
428
429 static grn_obj *
430 func_time_classify_month(grn_ctx *ctx, int n_args, grn_obj **args,
431 grn_user_data *user_data)
432 {
433 return func_time_classify_raw(ctx,
434 n_args,
435 args,
436 user_data,
437 "time_classify_month",
438 GRN_TIME_CLASSIFY_UNIT_MONTH);
439 }
440
441 static grn_obj *
442 func_time_classify_year(grn_ctx *ctx, int n_args, grn_obj **args,
443 grn_user_data *user_data)
444 {
445 return func_time_classify_raw(ctx,
446 n_args,
447 args,
448 user_data,
449 "time_classify_year",
450 GRN_TIME_CLASSIFY_UNIT_YEAR);
451 }
452
453 static grn_obj *
454 func_time_classify_day_of_week(grn_ctx *ctx, int n_args, grn_obj **args,
455 grn_user_data *user_data)
456 {
457 const char *function_name = "time_classify_day_of_week";
458 grn_obj *time;
459
460 if (n_args != 1) {
461 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
462 "%s(): "
463 "wrong number of arguments (%d for 1)",
464 function_name,
465 n_args);
466 return NULL;
467 }
468
469 time = args[0];
470 if (!(time->header.type == GRN_BULK &&
471 time->header.domain == GRN_DB_TIME)) {
472 grn_obj inspected;
473
474 GRN_TEXT_INIT(&inspected, 0);
475 grn_inspect(ctx, &inspected, time);
476 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
477 "%s(): "
478 "the first argument must be a time: "
479 "<%.*s>",
480 function_name,
481 (int)GRN_TEXT_LEN(&inspected),
482 GRN_TEXT_VALUE(&inspected));
483 GRN_OBJ_FIN(ctx, &inspected);
484 return NULL;
485 }
486
487 {
488 int64_t time_raw;
489 struct tm tm;
490 grn_obj *day_of_week;
491
492 time_raw = GRN_TIME_VALUE(time);
493 if (!grn_time_to_tm(ctx, time_raw, &tm)) {
494 return NULL;
495 }
496
497 day_of_week = grn_plugin_proc_alloc(ctx,
498 user_data,
499 GRN_DB_UINT8,
500 0);
501 if (!day_of_week) {
502 return NULL;
503 }
504 GRN_UINT8_SET(ctx, day_of_week, tm.tm_wday);
505
506 return day_of_week;
507 }
508 }
509
510 static grn_obj *
511 func_time_format(grn_ctx *ctx, int n_args, grn_obj **args,
512 grn_user_data *user_data)
513 {
514 grn_obj *time;
515 grn_obj *format;
516
517 if (n_args != 2) {
518 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
519 "time_format(): "
520 "wrong number of arguments (%d for 2)",
521 n_args);
522 return NULL;
523 }
524
525 time = args[0];
526 format = args[1];
527
528 if (!(time->header.type == GRN_BULK &&
529 time->header.domain == GRN_DB_TIME)) {
530 grn_obj inspected;
531
532 GRN_TEXT_INIT(&inspected, 0);
533 grn_inspect(ctx, &inspected, time);
534 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
535 "time_format(): "
536 "the first argument must be a time: "
537 "<%.*s>",
538 (int)GRN_TEXT_LEN(&inspected),
539 GRN_TEXT_VALUE(&inspected));
540 GRN_OBJ_FIN(ctx, &inspected);
541 return NULL;
542 }
543
544 if (!grn_obj_is_text_family_bulk(ctx, format)) {
545 grn_obj inspected;
546
547 GRN_TEXT_INIT(&inspected, 0);
548 grn_inspect(ctx, &inspected, format);
549 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
550 "time_format(): "
551 "the second argument must be a string: "
552 "<%.*s>",
553 (int)GRN_TEXT_LEN(&inspected),
554 GRN_TEXT_VALUE(&inspected));
555 GRN_OBJ_FIN(ctx, &inspected);
556 return NULL;
557 }
558
559 {
560 int64_t time_raw;
561 struct tm tm;
562 grn_obj nul_terminated_format;
563 grn_obj *formatted_time;
564 char formatted_time_buffer[4096];
565 size_t formatted_time_size;
566
567 time_raw = GRN_TIME_VALUE(time);
568 if (!grn_time_to_tm(ctx, time_raw, &tm)) {
569 return NULL;
570 }
571
572 GRN_TEXT_INIT(&nul_terminated_format, 0);
573 GRN_TEXT_SET(ctx,
574 &nul_terminated_format,
575 GRN_TEXT_VALUE(format),
576 GRN_TEXT_LEN(format));
577 GRN_TEXT_PUTC(ctx, &nul_terminated_format, '\0');
578
579 formatted_time_size = strftime(formatted_time_buffer,
580 sizeof(formatted_time_buffer),
581 GRN_TEXT_VALUE(&nul_terminated_format),
582 &tm);
583 GRN_OBJ_FIN(ctx, &nul_terminated_format);
584
585 formatted_time = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_TEXT, 0);
586 GRN_TEXT_SET(ctx,
587 formatted_time,
588 formatted_time_buffer,
589 formatted_time_size);
590
591 return formatted_time;
592 }
593 }
594
595 static grn_obj *
596 func_time_format_iso8601(grn_ctx *ctx, int n_args, grn_obj **args,
597 grn_user_data *user_data)
598 {
599 const char *function_name = "time_format_iso8601";
600 grn_obj *time;
601
602 if (n_args != 1) {
603 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
604 "%s(): "
605 "wrong number of arguments (%d for 1)",
606 function_name,
607 n_args);
608 return NULL;
609 }
610
611 time = args[0];
612
613 if (!(time->header.type == GRN_BULK &&
614 time->header.domain == GRN_DB_TIME)) {
615 grn_obj inspected;
616
617 GRN_TEXT_INIT(&inspected, 0);
618 grn_inspect(ctx, &inspected, time);
619 GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
620 "%s(): "
621 "the first argument must be a time: "
622 "<%.*s>",
623 function_name,
624 (int)GRN_TEXT_LEN(&inspected),
625 GRN_TEXT_VALUE(&inspected));
626 GRN_OBJ_FIN(ctx, &inspected);
627 return NULL;
628 }
629
630 {
631 int64_t time_raw;
632 struct tm tm;
633 int64_t time_sec;
634 int32_t time_usec;
635 grn_obj *formatted_time;
636
637 time_raw = GRN_TIME_VALUE(time);
638 if (!grn_time_to_tm(ctx, time_raw, &tm)) {
639 return NULL;
640 }
641
642 GRN_TIME_UNPACK(time_raw, time_sec, time_usec);
643
644 formatted_time = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_TEXT, 0);
645 if (!formatted_time) {
646 return NULL;
647 }
648
649 grn_text_printf(ctx,
650 formatted_time,
651 "%04d-%02d-%02dT%02d:%02d:%02d.%06d",
652 tm.tm_year + 1900,
653 tm.tm_mon + 1,
654 tm.tm_mday,
655 tm.tm_hour,
656 tm.tm_min,
657 tm.tm_sec,
658 time_usec);
659 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
660 grn_text_printf(ctx,
661 formatted_time,
662 "%+03d:%02d",
663 (int32_t)(tm.tm_gmtoff / 3600),
664 abs((int32_t)(tm.tm_gmtoff % 3600)));
665 #elif defined(HAVE_TIMEGM) /* HAVE_STRUCT_TM_TM_GMTOFF */
666 {
667 time_t gmtoff = timegm(&tm) - time_sec;
668 grn_text_printf(ctx,
669 formatted_time,
670 "%+03d:%02d",
671 (int32_t)(gmtoff / 3600),
672 abs((int32_t)(gmtoff % 3600)));
673 }
674 #endif /* HAVE_STRUCT_TM_TM_GMTOFF */
675 return formatted_time;
676 }
677 }
678
679 grn_rc
680 GRN_PLUGIN_INIT(grn_ctx *ctx)
681 {
682 return ctx->rc;
683 }
684
685 grn_rc
686 GRN_PLUGIN_REGISTER(grn_ctx *ctx)
687 {
688 grn_rc rc = GRN_SUCCESS;
689
690 grn_proc_create(ctx,
691 "time_classify_second", -1,
692 GRN_PROC_FUNCTION,
693 func_time_classify_second,
694 NULL, NULL, 0, NULL);
695 grn_proc_create(ctx,
696 "time_classify_minute", -1,
697 GRN_PROC_FUNCTION,
698 func_time_classify_minute,
699 NULL, NULL, 0, NULL);
700 grn_proc_create(ctx,
701 "time_classify_hour", -1,
702 GRN_PROC_FUNCTION,
703 func_time_classify_hour,
704 NULL, NULL, 0, NULL);
705 grn_proc_create(ctx,
706 "time_classify_day", -1,
707 GRN_PROC_FUNCTION,
708 func_time_classify_day,
709 NULL, NULL, 0, NULL);
710 grn_proc_create(ctx,
711 "time_classify_week", -1,
712 GRN_PROC_FUNCTION,
713 func_time_classify_week,
714 NULL, NULL, 0, NULL);
715 grn_proc_create(ctx,
716 "time_classify_month", -1,
717 GRN_PROC_FUNCTION,
718 func_time_classify_month,
719 NULL, NULL, 0, NULL);
720 grn_proc_create(ctx,
721 "time_classify_year", -1,
722 GRN_PROC_FUNCTION,
723 func_time_classify_year,
724 NULL, NULL, 0, NULL);
725 grn_proc_create(ctx,
726 "time_classify_day_of_week", -1,
727 GRN_PROC_FUNCTION,
728 func_time_classify_day_of_week,
729 NULL, NULL, 0, NULL);
730
731 grn_proc_create(ctx,
732 "time_format", -1,
733 GRN_PROC_FUNCTION,
734 func_time_format,
735 NULL, NULL, 0, NULL);
736 grn_proc_create(ctx,
737 "time_format_iso8601", -1,
738 GRN_PROC_FUNCTION,
739 func_time_format_iso8601,
740 NULL, NULL, 0, NULL);
741
742 return rc;
743 }
744
745 grn_rc
746 GRN_PLUGIN_FIN(grn_ctx *ctx)
747 {
748 return GRN_SUCCESS;
749 }