goja icon indicating copy to clipboard operation
goja copied to clipboard

Builtin Date locale's methods ignore locale argument

Open olegbespalov opened this issue 1 year ago • 2 comments

What?

One of the k6's users reported that using the Date().toLocaleDateString() always returns the date in the same format.

Date().toLocaleDateString('en-US') Expect 12/30/2012 : Actual 12/30/2012
Date().toLocaleDateString('en-CA') Expect 2012-12-30 : Actual 12/30/2012
Date().toLocaleDateString('en-GB') Expect 30/12/2012 : Actual 12/30/2012
Date().toLocaleDateString('de-DE') Expect 30.12.2012 : Actual 12/30/2012

It's happening since internally, the only dateLayout_en_GB is used, and we don't take into account any arguments.

Probably, that's not what most users will expect.

Why?

Fixing this will help satisfy users' expectations.

olegbespalov avatar May 24 '24 10:05 olegbespalov

I don't see how it's possible without involving a 3rd party library, any suggestions?

dop251 avatar Jun 03 '24 17:06 dop251

I fix the bug: https://github.com/dop251/goja/pull/633.

linkxzhou avatar Dec 26 '24 01:12 linkxzhou