- Timestamp:
- Jul 9, 2020, 8:51:43 AM (4 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-2.1.1
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-2.1.1/mrbgems/mruby-time/src/time.c
r331 r439 5 5 */ 6 6 7 #ifndef MRB_WITHOUT_FLOAT 7 8 #include <math.h> 8 #include <time.h> 9 #endif 10 9 11 #include <mruby.h> 10 12 #include <mruby/class.h> 11 13 #include <mruby/data.h> 12 13 #i fndef DISABLE_STDIO14 #include <stdio.h> 15 # else14 #include <mruby/numeric.h> 15 #include <mruby/time.h> 16 17 #ifdef MRB_DISABLE_STDIO 16 18 #include <string.h> 17 19 #endif 18 20 21 #include <stdlib.h> 22 19 23 #define NDIV(x,y) (-(-((x)+1)/(y))-1) 20 21 #if _MSC_VER < 1800 24 #define TO_S_FMT "%Y-%m-%d %H:%M:%S " 25 26 #if defined(_MSC_VER) && _MSC_VER < 1800 22 27 double round(double x) { 23 if (x >= 0.0) { 24 return (double)((int)(x + 0.5)); 25 } 26 else { 27 return (double)((int)(x - 0.5)); 28 } 29 } 30 #endif 31 32 #if !defined(__MINGW64__) && defined(_WIN32) 33 # define llround(x) round(x) 28 return floor(x + 0.5); 29 } 30 #endif 31 32 #ifndef MRB_WITHOUT_FLOAT 33 # if !defined(__MINGW64__) && defined(_WIN32) 34 # define llround(x) round(x) 35 # endif 34 36 #endif 35 37 … … 52 54 53 55 #ifdef _WIN32 54 #if _MSC_VER56 #ifdef _MSC_VER 55 57 /* Win32 platform do not provide gmtime_r/localtime_r; emulate them using gmtime_s/localtime_s */ 56 58 #define gmtime_r(tp, tm) ((gmtime_s((tm), (tp)) == 0) ? (tm) : NULL) … … 144 146 unsigned int *nday = (unsigned int*) ndays[is_leapyear(tm->tm_year+1900)]; 145 147 146 for (i = 70; i < tm->tm_year; ++i) 147 r += is_leapyear(i+1900) ? 366*24*60*60 : 365*24*60*60; 148 static const int epoch_year = 70; 149 if(tm->tm_year >= epoch_year) { 150 for (i = epoch_year; i < tm->tm_year; ++i) 151 r += is_leapyear(i+1900) ? 366*24*60*60 : 365*24*60*60; 152 } else { 153 for (i = tm->tm_year; i < epoch_year; ++i) 154 r -= is_leapyear(i+1900) ? 366*24*60*60 : 365*24*60*60; 155 } 148 156 for (i = 0; i < tm->tm_mon; ++i) 149 157 r += nday[i] * 24 * 60 * 60; … … 161 169 */ 162 170 163 enum mrb_timezone {164 MRB_TIMEZONE_NONE = 0,165 MRB_TIMEZONE_UTC = 1,166 MRB_TIMEZONE_LOCAL = 2,167 MRB_TIMEZONE_LAST = 3168 };169 170 171 typedef struct mrb_timezone_name { 171 172 const char name[8]; … … 179 180 }; 180 181 181 #ifndef DISABLE_STDIO182 #ifndef MRB_DISABLE_STDIO 182 183 static const char mon_names[12][4] = { 183 184 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", … … 198 199 static const struct mrb_data_type mrb_time_type = { "Time", mrb_free }; 199 200 201 #ifndef MRB_WITHOUT_FLOAT 202 void mrb_check_num_exact(mrb_state *mrb, mrb_float num); 203 typedef mrb_float mrb_sec; 204 #define mrb_sec_value(mrb, sec) mrb_float_value(mrb, sec) 205 #else 206 typedef mrb_int mrb_sec; 207 #define mrb_sec_value(mrb, sec) mrb_fixnum_value(sec) 208 #endif 209 210 #define MRB_TIME_T_UINT (~(time_t)0 > 0) 211 #define MRB_TIME_MIN ( \ 212 MRB_TIME_T_UINT ? 0 : \ 213 (sizeof(time_t) <= 4 ? INT32_MIN : INT64_MIN) \ 214 ) 215 #define MRB_TIME_MAX ( \ 216 MRB_TIME_T_UINT ? (sizeof(time_t) <= 4 ? UINT32_MAX : UINT64_MAX) : \ 217 (sizeof(time_t) <= 4 ? INT32_MAX : INT64_MAX) \ 218 ) 219 220 static mrb_bool 221 fixable_time_t_p(time_t v) 222 { 223 if (MRB_INT_MIN <= MRB_TIME_MIN && MRB_TIME_MAX <= MRB_INT_MAX) return TRUE; 224 return FIXABLE(v); 225 } 226 227 static time_t 228 mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec) 229 { 230 time_t t; 231 232 switch (mrb_type(obj)) { 233 #ifndef MRB_WITHOUT_FLOAT 234 case MRB_TT_FLOAT: 235 { 236 mrb_float f = mrb_float(obj); 237 238 mrb_check_num_exact(mrb, f); 239 if (f >= ((mrb_float)MRB_TIME_MAX-1.0) || f < ((mrb_float)MRB_TIME_MIN+1.0)) { 240 goto out_of_range; 241 } 242 243 if (usec) { 244 t = (time_t)f; 245 *usec = (time_t)llround((f - t) * 1.0e+6); 246 } 247 else { 248 t = (time_t)llround(f); 249 } 250 } 251 break; 252 #endif /* MRB_WITHOUT_FLOAT */ 253 default: 254 case MRB_TT_FIXNUM: 255 { 256 mrb_int i = mrb_int(mrb, obj); 257 258 if ((MRB_INT_MAX > MRB_TIME_MAX && i > 0 && i > (mrb_int)MRB_TIME_MAX) || 259 (MRB_TIME_MIN > MRB_INT_MIN && MRB_TIME_MIN > i)) { 260 goto out_of_range; 261 } 262 263 t = (time_t)i; 264 if (usec) { *usec = 0; } 265 } 266 break; 267 } 268 269 return t; 270 271 out_of_range: 272 mrb_raisef(mrb, E_ARGUMENT_ERROR, "%v out of Time range", obj); 273 274 /* not reached */ 275 if (usec) { *usec = 0; } 276 return 0; 277 } 278 200 279 /** Updates the datetime of a mrb_time based on it's timezone and 201 seconds setting. Returns self on success, NULL of failure. */ 280 seconds setting. Returns self on success, NULL of failure. 281 if `dealloc` is set `true`, it frees `self` on error. */ 202 282 static struct mrb_time* 203 time_update_datetime(mrb_state *mrb, struct mrb_time *self )283 time_update_datetime(mrb_state *mrb, struct mrb_time *self, int dealloc) 204 284 { 205 285 struct tm *aid; 286 time_t t = self->sec; 206 287 207 288 if (self->timezone == MRB_TIMEZONE_UTC) { 208 aid = gmtime_r(& self->sec, &self->datetime);289 aid = gmtime_r(&t, &self->datetime); 209 290 } 210 291 else { 211 aid = localtime_r(& self->sec, &self->datetime);292 aid = localtime_r(&t, &self->datetime); 212 293 } 213 294 if (!aid) { 214 mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S out of Time range", mrb_float_value(mrb, (mrb_float)self->sec)); 295 mrb_sec sec = (mrb_sec)t; 296 297 if (dealloc) mrb_free(mrb, self); 298 mrb_raisef(mrb, E_ARGUMENT_ERROR, "%v out of Time range", mrb_sec_value(mrb, sec)); 215 299 /* not reached */ 216 300 return NULL; … … 229 313 } 230 314 231 void mrb_check_num_exact(mrb_state *mrb, mrb_float num);232 233 315 /* Allocates a mrb_time object and initializes it. */ 234 316 static struct mrb_time* 235 time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone) 236 { 237 struct mrb_time *tm; 238 time_t tsec = 0; 239 240 mrb_check_num_exact(mrb, (mrb_float)sec); 241 mrb_check_num_exact(mrb, (mrb_float)usec); 242 243 if (sizeof(time_t) == 4 && (sec > (double)INT32_MAX || (double)INT32_MIN > sec)) { 244 goto out_of_range; 245 } 246 if (sizeof(time_t) == 8 && (sec > (double)INT64_MAX || (double)INT64_MIN > sec)) { 247 goto out_of_range; 248 } 249 tsec = (time_t)sec; 250 if ((sec > 0 && tsec < 0) || (sec < 0 && (double)tsec > sec)) { 251 out_of_range: 252 mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S out of Time range", mrb_float_value(mrb, sec)); 253 } 317 time_alloc_time(mrb_state *mrb, time_t sec, time_t usec, enum mrb_timezone timezone) 318 { 319 struct mrb_time *tm; 320 254 321 tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(struct mrb_time)); 255 tm->sec = tsec;256 tm->usec = (time_t)llround((sec - tm->sec) * 1.0e6 + usec);322 tm->sec = sec; 323 tm->usec = usec; 257 324 if (tm->usec < 0) { 258 long sec2 = (long)NDIV( usec,1000000); /* negative div */325 long sec2 = (long)NDIV(tm->usec,1000000); /* negative div */ 259 326 tm->usec -= sec2 * 1000000; 260 327 tm->sec += sec2; 261 328 } 262 329 else if (tm->usec >= 1000000) { 263 long sec2 = (long)( usec / 1000000);330 long sec2 = (long)(tm->usec / 1000000); 264 331 tm->usec -= sec2 * 1000000; 265 332 tm->sec += sec2; 266 333 } 267 334 tm->timezone = timezone; 268 time_update_datetime(mrb, tm );335 time_update_datetime(mrb, tm, TRUE); 269 336 270 337 return tm; 271 338 } 272 339 273 static mrb_value 274 mrb_time_make(mrb_state *mrb, struct RClass *c, double sec, double usec, enum mrb_timezone timezone) 340 static struct mrb_time* 341 time_alloc(mrb_state *mrb, mrb_value sec, mrb_value usec, enum mrb_timezone timezone) 342 { 343 time_t tsec, tusec; 344 345 tsec = mrb_to_time_t(mrb, sec, &tusec); 346 tusec += mrb_to_time_t(mrb, usec, NULL); 347 348 return time_alloc_time(mrb, tsec, tusec, timezone); 349 } 350 351 static mrb_value 352 mrb_time_make_time(mrb_state *mrb, struct RClass *c, time_t sec, time_t usec, enum mrb_timezone timezone) 353 { 354 return mrb_time_wrap(mrb, c, time_alloc_time(mrb, sec, usec, timezone)); 355 } 356 357 static mrb_value 358 mrb_time_make(mrb_state *mrb, struct RClass *c, mrb_value sec, mrb_value usec, enum mrb_timezone timezone) 275 359 { 276 360 return mrb_time_wrap(mrb, c, time_alloc(mrb, sec, usec, timezone)); … … 280 364 current_mrb_time(mrb_state *mrb) 281 365 { 282 struct mrb_time *tm; 283 284 tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm)); 285 #if defined(TIME_UTC) 366 struct mrb_time tmzero = {0}; 367 struct mrb_time *tm; 368 time_t sec, usec; 369 370 #if defined(TIME_UTC) && !defined(__ANDROID__) 286 371 { 287 372 struct timespec ts; 288 373 if (timespec_get(&ts, TIME_UTC) == 0) { 289 mrb_free(mrb, tm);290 374 mrb_raise(mrb, E_RUNTIME_ERROR, "timespec_get() failed for unknown reasons"); 291 375 } 292 tm->sec = ts.tv_sec;293 tm->usec = ts.tv_nsec / 1000;376 sec = ts.tv_sec; 377 usec = ts.tv_nsec / 1000; 294 378 } 295 379 #elif defined(NO_GETTIMEOFDAY) … … 297 381 static time_t last_sec = 0, last_usec = 0; 298 382 299 tm->sec= time(NULL);300 if ( tm->sec != last_sec) {301 last_sec = tm->sec;383 sec = time(NULL); 384 if (sec != last_sec) { 385 last_sec = sec; 302 386 last_usec = 0; 303 387 } … … 306 390 last_usec += 1; 307 391 } 308 tm->usec = last_usec;392 usec = last_usec; 309 393 } 310 394 #else … … 313 397 314 398 gettimeofday(&tv, NULL); 315 tm->sec = tv.tv_sec; 316 tm->usec = tv.tv_usec; 317 } 318 #endif 399 sec = tv.tv_sec; 400 usec = tv.tv_usec; 401 } 402 #endif 403 tm = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm)); 404 *tm = tmzero; 405 tm->sec = sec; tm->usec = usec; 319 406 tm->timezone = MRB_TIMEZONE_LOCAL; 320 time_update_datetime(mrb, tm );407 time_update_datetime(mrb, tm, TRUE); 321 408 322 409 return tm; … … 328 415 { 329 416 return mrb_time_wrap(mrb, mrb_class_ptr(self), current_mrb_time(mrb)); 417 } 418 419 MRB_API mrb_value 420 mrb_time_at(mrb_state *mrb, time_t sec, time_t usec, enum mrb_timezone zone) 421 { 422 return mrb_time_make_time(mrb, mrb_class_get(mrb, "Time"), sec, usec, zone); 330 423 } 331 424 … … 333 426 /* Creates an instance of time at the given time in seconds, etc. */ 334 427 static mrb_value 335 mrb_time_at(mrb_state *mrb, mrb_value self) 336 { 337 mrb_float f, f2 = 0; 338 339 mrb_get_args(mrb, "f|f", &f, &f2); 340 return mrb_time_make(mrb, mrb_class_ptr(self), f, f2, MRB_TIMEZONE_LOCAL); 428 mrb_time_at_m(mrb_state *mrb, mrb_value self) 429 { 430 mrb_value sec; 431 mrb_value usec = mrb_fixnum_value(0); 432 433 mrb_get_args(mrb, "o|o", &sec, &usec); 434 435 return mrb_time_make(mrb, mrb_class_ptr(self), sec, usec, MRB_TIMEZONE_LOCAL); 341 436 } 342 437 … … 375 470 } 376 471 377 return time_alloc (mrb, (double)nowsecs, ausec, timezone);472 return time_alloc_time(mrb, nowsecs, ausec, timezone); 378 473 } 379 474 … … 461 556 mrb_time_plus(mrb_state *mrb, mrb_value self) 462 557 { 463 mrb_float f; 464 struct mrb_time *tm; 465 466 mrb_get_args(mrb, "f", &f); 467 tm = time_get_ptr(mrb, self); 468 return mrb_time_make(mrb, mrb_obj_class(mrb, self), (double)tm->sec+f, (double)tm->usec, tm->timezone); 558 mrb_value o; 559 struct mrb_time *tm; 560 time_t sec, usec; 561 562 mrb_get_args(mrb, "o", &o); 563 tm = time_get_ptr(mrb, self); 564 sec = mrb_to_time_t(mrb, o, &usec); 565 return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), tm->sec+sec, tm->usec+usec, tm->timezone); 469 566 } 470 567 … … 472 569 mrb_time_minus(mrb_state *mrb, mrb_value self) 473 570 { 474 mrb_float f;475 571 mrb_value other; 476 572 struct mrb_time *tm, *tm2; … … 480 576 tm2 = DATA_CHECK_GET_PTR(mrb, other, &mrb_time_type, struct mrb_time); 481 577 if (tm2) { 482 f = (mrb_float)(tm->sec - tm2->sec) 483 + (mrb_float)(tm->usec - tm2->usec) / 1.0e6; 578 #ifndef MRB_WITHOUT_FLOAT 579 mrb_float f; 580 f = (mrb_sec)(tm->sec - tm2->sec) 581 + (mrb_sec)(tm->usec - tm2->usec) / 1.0e6; 484 582 return mrb_float_value(mrb, f); 583 #else 584 mrb_int f; 585 f = tm->sec - tm2->sec; 586 if (tm->usec < tm2->usec) f--; 587 return mrb_fixnum_value(f); 588 #endif 485 589 } 486 590 else { 487 mrb_get_args(mrb, "f", &f); 488 return mrb_time_make(mrb, mrb_obj_class(mrb, self), (double)tm->sec-f, (double)tm->usec, tm->timezone); 591 time_t sec, usec; 592 sec = mrb_to_time_t(mrb, other, &usec); 593 return mrb_time_make_time(mrb, mrb_obj_class(mrb, self), tm->sec-sec, tm->usec-usec, tm->timezone); 489 594 } 490 595 } … … 547 652 int len; 548 653 549 #if defined( DISABLE_STDIO)654 #if defined(MRB_DISABLE_STDIO) 550 655 char *s; 551 656 # ifdef NO_ASCTIME_R … … 559 664 char buf[256]; 560 665 561 len = snprintf(buf, sizeof(buf), "%s %s % 02d %02d:%02d:%02d %s%d",666 len = snprintf(buf, sizeof(buf), "%s %s %2d %02d:%02d:%02d %.4d", 562 667 wday_names[d->tm_wday], mon_names[d->tm_mon], d->tm_mday, 563 668 d->tm_hour, d->tm_min, d->tm_sec, 564 tm->timezone == MRB_TIMEZONE_UTC ? "UTC " : "",565 669 d->tm_year + 1900); 566 670 #endif … … 603 707 *tm2 = *tm; 604 708 tm2->timezone = MRB_TIMEZONE_UTC; 605 time_update_datetime(mrb, tm2 );709 time_update_datetime(mrb, tm2, TRUE); 606 710 return mrb_time_wrap(mrb, mrb_obj_class(mrb, self), tm2); 607 711 } … … 618 722 *tm2 = *tm; 619 723 tm2->timezone = MRB_TIMEZONE_LOCAL; 620 time_update_datetime(mrb, tm2 );724 time_update_datetime(mrb, tm2, TRUE); 621 725 return mrb_time_wrap(mrb, mrb_obj_class(mrb, self), tm2); 622 726 } … … 640 744 mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, 641 745 amin = 0, asec = 0, ausec = 0; 642 int n;746 mrb_int n; 643 747 struct mrb_time *tm; 644 748 … … 696 800 tm = time_get_ptr(mrb, self); 697 801 tm->timezone = MRB_TIMEZONE_LOCAL; 698 time_update_datetime(mrb, tm );802 time_update_datetime(mrb, tm, FALSE); 699 803 return self; 700 804 } … … 744 848 } 745 849 746 850 #ifndef MRB_WITHOUT_FLOAT 747 851 /* 15.2.19.7.24 */ 748 852 /* Returns a Float with the time since the epoch in seconds. */ … … 755 859 return mrb_float_value(mrb, (mrb_float)tm->sec + (mrb_float)tm->usec/1.0e6); 756 860 } 861 #endif 757 862 758 863 /* 15.2.19.7.25 */ 759 /* Returns a Fixnumwith the time since the epoch in seconds. */864 /* Returns an Integer with the time since the epoch in seconds. */ 760 865 static mrb_value 761 866 mrb_time_to_i(mrb_state *mrb, mrb_value self) … … 764 869 765 870 tm = time_get_ptr(mrb, self); 766 if (tm->sec > MRB_INT_MAX || tm->sec < MRB_INT_MIN) { 871 #ifndef MRB_WITHOUT_FLOAT 872 if (!fixable_time_t_p(tm->sec)) { 767 873 return mrb_float_value(mrb, (mrb_float)tm->sec); 768 874 } 875 #endif 769 876 return mrb_fixnum_value((mrb_int)tm->sec); 770 877 } 771 878 772 879 /* 15.2.19.7.26 */ 773 /* Returns a Floatwith the time since the epoch in microseconds. */880 /* Returns an Integer with the time since the epoch in microseconds. */ 774 881 static mrb_value 775 882 mrb_time_usec(mrb_state *mrb, mrb_value self) … … 778 885 779 886 tm = time_get_ptr(mrb, self); 780 if (tm->usec > MRB_INT_MAX || tm->usec < MRB_INT_MIN) { 887 #ifndef MRB_WITHOUT_FLOAT 888 if (!fixable_time_t_p(tm->usec)) { 781 889 return mrb_float_value(mrb, (mrb_float)tm->usec); 782 890 } 891 #endif 783 892 return mrb_fixnum_value((mrb_int)tm->usec); 784 893 } … … 793 902 tm = time_get_ptr(mrb, self); 794 903 tm->timezone = MRB_TIMEZONE_UTC; 795 time_update_datetime(mrb, tm );904 time_update_datetime(mrb, tm, FALSE); 796 905 return self; 797 906 } … … 808 917 } 809 918 919 static size_t 920 time_to_s_utc(mrb_state *mrb, struct mrb_time *tm, char *buf, size_t buf_len) 921 { 922 return strftime(buf, buf_len, TO_S_FMT "UTC", &tm->datetime); 923 } 924 925 static size_t 926 time_to_s_local(mrb_state *mrb, struct mrb_time *tm, char *buf, size_t buf_len) 927 { 928 #if defined(_MSC_VER) && _MSC_VER < 1900 || defined(__MINGW64__) || defined(__MINGW32__) 929 struct tm datetime = {0}; 930 time_t utc_sec = timegm(&tm->datetime); 931 size_t len; 932 int offset; 933 934 if (utc_sec == (time_t)-1) { 935 mrb_raise(mrb, E_ARGUMENT_ERROR, "Not a valid time."); 936 } 937 offset = abs((int)(utc_sec - tm->sec) / 60); 938 datetime.tm_year = 100; 939 datetime.tm_hour = offset / 60; 940 datetime.tm_min = offset % 60; 941 len = strftime(buf, buf_len, TO_S_FMT, &tm->datetime); 942 buf[len++] = utc_sec < tm->sec ? '-' : '+'; 943 944 return len + strftime(buf + len, buf_len - len, "%H%M", &datetime); 945 #else 946 return strftime(buf, buf_len, TO_S_FMT "%z", &tm->datetime); 947 #endif 948 } 949 950 static mrb_value 951 mrb_time_to_s(mrb_state *mrb, mrb_value self) 952 { 953 char buf[64]; 954 struct mrb_time *tm = time_get_ptr(mrb, self); 955 mrb_bool utc = tm->timezone == MRB_TIMEZONE_UTC; 956 size_t len = (utc ? time_to_s_utc : time_to_s_local)(mrb, tm, buf, sizeof(buf)); 957 return mrb_str_new(mrb, buf, len); 958 } 810 959 811 960 void … … 817 966 MRB_SET_INSTANCE_TT(tc, MRB_TT_DATA); 818 967 mrb_include_module(mrb, tc, mrb_module_get(mrb, "Comparable")); 819 mrb_define_class_method(mrb, tc, "at", mrb_time_at , MRB_ARGS_ARG(1, 1)); /* 15.2.19.6.1 */968 mrb_define_class_method(mrb, tc, "at", mrb_time_at_m, MRB_ARGS_ARG(1, 1)); /* 15.2.19.6.1 */ 820 969 mrb_define_class_method(mrb, tc, "gm", mrb_time_gm, MRB_ARGS_ARG(1,6)); /* 15.2.19.6.2 */ 821 970 mrb_define_class_method(mrb, tc, "local", mrb_time_local, MRB_ARGS_ARG(1,6)); /* 15.2.19.6.3 */ … … 828 977 mrb_define_method(mrb, tc, "+" , mrb_time_plus , MRB_ARGS_REQ(1)); /* 15.2.19.7.2 */ 829 978 mrb_define_method(mrb, tc, "-" , mrb_time_minus , MRB_ARGS_REQ(1)); /* 15.2.19.7.3 */ 830 mrb_define_method(mrb, tc, "to_s" , mrb_time_ asctime, MRB_ARGS_NONE());831 mrb_define_method(mrb, tc, "inspect", mrb_time_ asctime, MRB_ARGS_NONE());979 mrb_define_method(mrb, tc, "to_s" , mrb_time_to_s , MRB_ARGS_NONE()); 980 mrb_define_method(mrb, tc, "inspect", mrb_time_to_s , MRB_ARGS_NONE()); 832 981 mrb_define_method(mrb, tc, "asctime", mrb_time_asctime, MRB_ARGS_NONE()); /* 15.2.19.7.4 */ 833 982 mrb_define_method(mrb, tc, "ctime" , mrb_time_asctime, MRB_ARGS_NONE()); /* 15.2.19.7.5 */ … … 849 998 mrb_define_method(mrb, tc, "sec" , mrb_time_sec, MRB_ARGS_NONE()); /* 15.2.19.7.23 */ 850 999 mrb_define_method(mrb, tc, "to_i", mrb_time_to_i, MRB_ARGS_NONE()); /* 15.2.19.7.25 */ 1000 #ifndef MRB_WITHOUT_FLOAT 851 1001 mrb_define_method(mrb, tc, "to_f", mrb_time_to_f, MRB_ARGS_NONE()); /* 15.2.19.7.24 */ 1002 #endif 852 1003 mrb_define_method(mrb, tc, "usec", mrb_time_usec, MRB_ARGS_NONE()); /* 15.2.19.7.26 */ 853 1004 mrb_define_method(mrb, tc, "utc" , mrb_time_utc, MRB_ARGS_NONE()); /* 15.2.19.7.27 */
Note:
See TracChangeset
for help on using the changeset viewer.