New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeJS not applying date locales properly #8500

Closed
wilkyboy opened this Issue Sep 12, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@wilkyboy

wilkyboy commented Sep 12, 2016

In all three of my environments I was able to reproduce this error:

My production server

  • Version: v6.5.0
  • Platform: Linux 2.srv.wilkynet.uk 4.4.11-x1-64+ #1 SMP Fri May 20 14:04:36 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: core js?

My primary development machine

  • Version: v4.4.0
  • Platform: Microsoft Windows [Version 10.0.10586] x64
  • Subsystem: core js?

My secondary development machine

  • Version: v4.3.1
  • Platform: Darwin Ben Wilkinson's MacBook Pro 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
  • Subsystem: core js?

I can't get nodejs to properly format a datetime string in the machine locale. On all of these machines the locale is set to British English, and when recreated on each machine, I get the same output, so I'll just post it once.

The expected behaviour is as such with the en-GB locale set:

> new Date().toLocaleString();
'12/09/2016, 18:14:37'
> new Date().toLocaleString('en-GB');
'12/09/2016, 18:15:31'
> new Date().toLocaleString('en-US');
'9/12/2016, 6:15:34 PM'

I get:

> new Date().toLocaleString();
'9/12/2016, 6:14:37 PM'
> new Date().toLocaleString('en-GB');
'9/12/2016, 6:15:31 PM'
> new Date().toLocaleString('en-US');
'9/12/2016, 6:15:34 PM'

However, when tested in the chrome console, I get the following:

new Date().toLocaleString();
"12/09/2016, 18:03:03"
new Date().toLocaleString('en-GB');
"12/09/2016, 18:03:08"
new Date().toLocaleString('en-US');
"9/12/2016, 6:03:11 PM"

What's going on here? Am I doing something wrong, or is there a bug here?

@wilkyboy wilkyboy changed the title from NodeJS not applying locales properly to NodeJS not applying date locales properly Sep 12, 2016

@mscdex

This comment has been minimized.

Show comment
Hide comment
@mscdex

mscdex Sep 12, 2016

Contributor

By default --with-intl=small-icu is used to build node, which contains just the en-US locale (@nodejs/intl -- is this correct or does it contain more?). You will need to either build node with --with-intl=full-icu or --with-intl=system-icu if you want to be able to use more locales. The reason node is built with a smaller ICU by default is file size.

Contributor

mscdex commented Sep 12, 2016

By default --with-intl=small-icu is used to build node, which contains just the en-US locale (@nodejs/intl -- is this correct or does it contain more?). You will need to either build node with --with-intl=full-icu or --with-intl=system-icu if you want to be able to use more locales. The reason node is built with a smaller ICU by default is file size.

@mscdex mscdex removed the V8 Engine label Sep 12, 2016

@targos

This comment has been minimized.

Show comment
Hide comment
@targos

targos Sep 12, 2016

Member

There is another option that doesn't require a custom build of node. You can install the full-icu module.

Member

targos commented Sep 12, 2016

There is another option that doesn't require a custom build of node. You can install the full-icu module.

@wilkyboy

This comment has been minimized.

Show comment
Hide comment
@wilkyboy

wilkyboy Sep 12, 2016

Thank you! At least this is now up somewhere where others can find it.

wilkyboy commented Sep 12, 2016

Thank you! At least this is now up somewhere where others can find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment