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