Skip to content

Output from Date.getLocaleString('de') looks different on Windows #29338

Closed

Description

@MareikeTaeubner
  • Version: 12.9.1, but I could also reproduce this with 12.7.0
  • Platform: Windows 10 64 bit
  • Subsystem:

new Date.toLocaleString('de') returns different formats depending on the platform.

Output on MacOs:
'27.8.2019, 11:23:00'

Output on Windows:
'2019-8-27 11:28:10'

For comparison output in Chrome developer console:
"27.8.2019, 11:32:00", which matches the format from MacOs.

Activity

  1. changed the title [-]new Date.getLocaleString('de') looks different on Windows[/-] [+]Output from Date.getLocaleString('de') looks different on Windows[/+] on Aug 27, 2019
  2. added
    i18n-api
    on Aug 27, 2019
  3. bnoordhuis commented on Aug 27, 2019

    @bnoordhuis
    Member

    I suspect you have full-icu installed on one machine but not the other.

    Either that or one of the node binaries is i18n-enabled while the other is not. Release binaries from https://nodejs.org/ are all i18n-enabled.

  4. MareikeTaeubner commented on Aug 27, 2019

    @MareikeTaeubner
    Author

    I have not installed full-icu on my windows machine (at least npm ls does not find it and I do not remember ever installing it) and on the macOs it was not found either. I installed Node.js via the windows installer from https://nodejs.org/en/ with the default settings. I reproduced the behavior via node console, after I have seen the different output in my log file from my electron app.

    I know that I did get the same output as on MacOs with electron 1.8.8 on this windows machine which should have contained node.js 8.2.1.

    Are there settings in the windows installer that I should have changed from default in the newer versions?

  5. bnoordhuis commented on Aug 27, 2019

    @bnoordhuis
    Member

    No, you don't have to (and can't) tweak anything in the installer. The release binaries are all i18n-enabled but they only ship the English locale; the full-icu package contains all the other locales.

    If you get proper localized output on your Mac, that means full-icu is installed. It's possible it's installed globally (npm install -g full-icu).

    If you upgraded Node.js on your Windows machine, the full-icu package probably needs to be upgraded as well.

  6. MareikeTaeubner commented on Aug 27, 2019

    @MareikeTaeubner
    Author

    npm ls -g full-icu /usr/local/lib └── (empty) It does not seem to be installed on mac.

    After installing full-icu globally on my windows machine I do not see any difference.

     npm i full-icu -g
    C:\Users\taeubnerm\AppData\Roaming\npm\node-full-icu-path -> C:\Users\taeubnerm\                                                       AppData\Roaming\npm\node_modules\full-icu\node-icu-data.js
    
    > [email protected] postinstall C:\Users\taeubnerm\AppData\Roaming\npm\node_modules                                                       \full-icu
    > node postinstall.js
    
    npm install icu4c-data@64l (Node 12.9.1 and small-icu 64.2) -> icudt64l.dat
    full-icu$ C:\Program Files\nodejs\node.exe C:\Users\taeubnerm\AppData\Roaming\np                                                       m\node_modules\npm\bin\npm-cli.js install icu4c-data@64l
    + [email protected]
    added 1 package from 1 contributor in 61.277s
     √ icudt64l.dat (link)
    Node will use this ICU datafile if the environment variable NODE_ICU_DATA is set to “C:\Users\taeubnerm\AppData\Roaming\npm\node_modules\full-icu”
    or with node --icu-data-dir=C:\Users\taeubnerm\AppData\Roaming\npm\node_modules\full-icu YOURAPP.js
     For package.json:
    {"scripts":{"start":"node --icu-data-dir=C:\\Users\\taeubnerm\\AppData\\Roaming\\npm\\node_modules\\full-icu YOURAPP.js"}}
    
    By the way, if you have full data, running this in node:
    > new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
    ... will show “enero”. If it shows “January” you don't have full data.
    News: Please see https://github.com/icu-project/full-icu-npm/issues/6
    + [email protected]
    added 1 package from 1 contributor in 62.341s
    
    
    $ node
    Welcome to Node.js v12.9.1.
    Type ".help" for more information.
    > new Date().toLocaleString('de')
    '2019-8-27 12:46:31'
    >new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
    'M01'
    

    EDIT:
    After reading again, I set the NODE_ICU_DATA env variable and started a new shell, and now it works with the node console. I guess I have to figure out how it works with electron now.

    Thank you for your help.

  7. bnoordhuis commented on Aug 27, 2019

    @bnoordhuis
    Member

    I guess I have to figure out how it works with electron now.

    I'm fairly sure electron bundles the full ICU data.

    Happy to hear it's working now. I'll close out the issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    i18n-api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions