|
|
@ -12,13 +12,15 @@ hours 3 |
|
|
|
minutes 4 |
|
|
|
seconds 5 |
|
|
|
milliseconds 6 |
|
|
|
weekday 6 |
|
|
|
year: 2016 |
|
|
|
month: 1 |
|
|
|
month: 0 |
|
|
|
day: 2 |
|
|
|
hour: 3 |
|
|
|
minute: 4 |
|
|
|
second: 5 |
|
|
|
millisecond: 6.000000 |
|
|
|
weekday: 6 |
|
|
|
final top: 0 |
|
|
|
==> rc=0, result='undefined' |
|
|
|
===*/ |
|
|
@ -31,7 +33,8 @@ static duk_ret_t test_1(duk_context *ctx, void *udata) { |
|
|
|
/* Ecmascript time-to-components (UTC):
|
|
|
|
* |
|
|
|
* - d.getUTCMonth() is zero-based. |
|
|
|
* - d.getUTCDate() is one-based. |
|
|
|
* - d.getUTCDate() (day in month) is one-based. |
|
|
|
* - d.getUTCDay() (weekday) is zero-based. |
|
|
|
*/ |
|
|
|
|
|
|
|
duk_eval_string_noresult(ctx, |
|
|
@ -45,13 +48,10 @@ static duk_ret_t test_1(duk_context *ctx, void *udata) { |
|
|
|
" print('minutes', d.getUTCMinutes());\n" |
|
|
|
" print('seconds', d.getUTCSeconds());\n" |
|
|
|
" print('milliseconds', d.getUTCMilliseconds());\n" |
|
|
|
" print('weekday', d.getUTCDay());\n" |
|
|
|
"})();"); |
|
|
|
|
|
|
|
/* C API equivalent:
|
|
|
|
* |
|
|
|
* - comp.month is one-based. |
|
|
|
* - comp.day is one-based. |
|
|
|
*/ |
|
|
|
/* C API equivalent. */ |
|
|
|
|
|
|
|
duk_time_to_components(ctx, 1451703845006.0, &comp); |
|
|
|
printf("year: %d\n", (int) comp.year); |
|
|
@ -61,6 +61,7 @@ static duk_ret_t test_1(duk_context *ctx, void *udata) { |
|
|
|
printf("minute: %d\n", (int) comp.minute); |
|
|
|
printf("second: %d\n", (int) comp.second); |
|
|
|
printf("millisecond: %lf\n", (double) comp.millisecond); |
|
|
|
printf("weekday: %d\n", (int) comp.weekday); |
|
|
|
|
|
|
|
printf("final top: %ld\n", (long) duk_get_top(ctx)); |
|
|
|
return 0; |
|
|
@ -100,16 +101,14 @@ static duk_ret_t test_2(duk_context *ctx, void *udata) { |
|
|
|
" print(d.valueOf())\n" |
|
|
|
"})();"); |
|
|
|
|
|
|
|
/* C API equivalent:
|
|
|
|
/* C API equivalent; note that:
|
|
|
|
* |
|
|
|
* - No special handling for two-digit years. |
|
|
|
* - comp.month is one-based. |
|
|
|
* - comp.day is one-based. |
|
|
|
*/ |
|
|
|
|
|
|
|
memset((void *) &comp, 0, sizeof(comp)); |
|
|
|
comp.year = 2016; |
|
|
|
comp.month = 1; |
|
|
|
comp.month = 0; |
|
|
|
comp.day = 2; |
|
|
|
comp.hour = 3; |
|
|
|
comp.minute = 4; |
|
|
@ -122,7 +121,7 @@ static duk_ret_t test_2(duk_context *ctx, void *udata) { |
|
|
|
|
|
|
|
memset((void *) &comp, 0, sizeof(comp)); |
|
|
|
comp.year = 2016; |
|
|
|
comp.month = 1; |
|
|
|
comp.month = 0; |
|
|
|
comp.day = 2; |
|
|
|
comp.hour = 3; |
|
|
|
comp.minute = 0; |
|
|
|