Deno: IANA TimeZone Support

Created on 1 Feb 2019  路  5Comments  路  Source: denoland/deno

deno: 0.2.8
v8: 7.2.502.16
typescript: 3.2.1

Run the following in both node and deno:

new Date().toLocaleString("en-US", {timeZone: "America/Halifax"});
new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
new Date().toLocaleString("en-US", {timeZone: "America/Chicago"});
new Date().toLocaleString("en-US", {timeZone: "America/Denver"});
new Date().toLocaleString("en-US", {timeZone: "America/Los_Angeles"});
new Date().toLocaleString("en-US", {timeZone: "America/Anchorage"});
new Date().toLocaleString("en-US", {timeZone: "Pacific/Honolulu"});

Deno returns incorrect times. It doesn't appear to support the IANA time zones yet.

Most helpful comment

All 5 comments

The Date() object comes directly from V8. Deno currently does nothing with it, but the behaviour is quite a lot different:

Deno

> new Date().toLocaleString("en-US", {timeZone: "Pacific/Honolulu"});
Fri Feb 01 2019 16:09:28 GMT+1000 (AEST)

Node.js v8.11.4

> new Date().toLocaleString("en-US", {timeZone: "Pacific/Honolulu"});
'1/31/2019, 8:09:11 PM'

Chrome 71.0.3578.98

> new Date().toLocaleString("en-US", {timeZone: "Pacific/Honolulu"});
"1/31/2019, 8:04:45 PM"

Exactly. The "en-US" argument has no effect on the date/time format, and the specified IANA timezone argument is ignored too.

Maybe V8 depends on its host (slightly) to facilitate this functionality and that slight thing isn't "wired up" yet in deno? Not sure.....

Perhaps the spec might reveal something:
http://www.ecma-international.org/ecma-402/5.0/index.html#sup-date.prototype.tolocalestring

Side note: I just submitted a bug to Chromium that reports two official time zones that it doesn't currently support.

@kishiguro made some progress on compiling deno with ICU embedded. It added 14MB to the final Deno executable. His instructions are here:
https://github.com/denoland/deno/issues/1968#issuecomment-633204393

Was this page helpful?
0 / 5 - 0 ratings

Related issues

somombo picture somombo  路  3Comments

sh7dm picture sh7dm  路  3Comments

ry picture ry  路  3Comments

xueqingxiao picture xueqingxiao  路  3Comments

ry picture ry  路  3Comments