Issue 491802 in chromium: Date.toLocaleString: timeZoneName=short breaks hour12=false

68 views
Skip to first unread message

chro...@googlecode.com

unread,
May 25, 2015, 2:50:47 AM5/25/15
to chromi...@chromium.org
Status: Unconfirmed
Owner: ----
Labels: OS-Linux Type-Bug Pri-2

New issue 491802 by e...@google.com: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802

Chrome Version : 43.0.2357.65

What steps will reproduce the problem?

(new Date(0)).toLocaleString('en-US', {timeZone: 'America/Los_Angeles',
hour12: false })
"12/31/1969, 16:00:00" <-- ok

(new Date(0)).toLocaleString('en-US', {timeZone: 'America/Los_Angeles',
hour12: false, timeZoneName: 'short' })
"12/31/1969, 4:00:00 PM PST" <-- not ok

What is the expected result?

"12/31/1969, 16:00:00 PST"

UserAgentString: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/43.0.2357.65 Safari/537.36


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
May 25, 2015, 2:51:47 AM5/25/15
to chromi...@chromium.org
Updates:
Labels: Hotlist-Google

Comment #1 on issue 491802 by vivi...@chromium.org: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802#c1

This is an automated update generated by script.

chro...@googlecode.com

unread,
May 26, 2015, 2:32:55 AM5/26/15
to chromi...@chromium.org
Updates:
Labels: Needs-Feedback

Comment #2 on issue 491802 by kavv...@chromium.org: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802

Thanks for reporting.

could you please provide us the repro steps and screenshot of the issue to
triage the further.

chro...@googlecode.com

unread,
May 26, 2015, 3:22:09 AM5/26/15
to chromi...@chromium.org

Comment #3 on issue 491802 by e...@google.com: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802

The repro step is you open javascript console, you enter:

(new Date(0)).toLocaleString('en-US', {timeZone: 'America/Los_Angeles',
hour12: false, timeZoneName: 'short' })

The answer you get back is:

"12/31/1969, 4:00:00 PM PST"

Which I think is the wrong answer.

chro...@googlecode.com

unread,
May 28, 2015, 1:06:30 AM5/28/15
to chromi...@chromium.org
Updates:
Cc: js...@chromium.org c...@chromium.org
Labels: Cr-Blink-JavaScript

Comment #4 on issue 491802 by tk...@chromium.org: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jun 9, 2015, 3:58:50 AM6/9/15
to chromi...@chromium.org

Comment #5 on issue 491802 by e...@google.com: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802

FYI this also affects Intl.DateTimeFormat:

Run:

(new Intl.DateTimeFormat('en-US', {timeZone: 'America/Los_Angeles',
hour12: false, timeZoneName: 'short', year: 'numeric', month: 'numeric',
day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric'
})).format(new Date(0))

Result:

"12/31/1969, 4:00:00 PM PST"

chro...@googlecode.com

unread,
Jun 9, 2015, 6:20:09 AM6/9/15
to chromi...@chromium.org

Comment #6 on issue 491802 by ns...@google.com: Date.toLocaleString:
timeZoneName=short breaks hour12=false
https://code.google.com/p/chromium/issues/detail?id=491802

It looks like timeZoneName: ('short' or 'long') causes hour12 to be ignored
in the reverse case, too.

The result is incorrect with hours, minutes, and seconds displayed -
removing seconds results in the value of hour12 being handled correctly.

> (new Date(0)).toLocaleString('en-GB', {timeZone: 'America/Los_Angeles',
> timeZoneName: 'short', hour: 'numeric'})

< "16 PST"

(The 24-hour clock is default for en-GB.)

> (new Date(0)).toLocaleString('en-GB', {timeZone: 'America/Los_Angeles',
> timeZoneName: 'short', hour: 'numeric', hour12: true})

< "4 pm PST"

> (new Date(0)).toLocaleString('en-GB', {timeZone: 'America/Los_Angeles',
> timeZoneName: 'short', hour: 'numeric', hour12: true, minute: 'numeric'})

< "4:00 pm PST"

(These results are expected.)

> (new Date(0)).toLocaleString('en-GB', {timeZone: 'America/Los_Angeles',
> timeZoneName: 'short', hour: 'numeric', hour12: true, minute: 'numeric',
> second: 'numeric'})

< "16:00:00 PST"

(The value of hour12 is ignored - the results are similar if you
use 'en-US' and hour12: false.)
Reply all
Reply to author
Forward
0 new messages