Skip to content
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

manual localisation is not worked, at least for date & time related functions #795

Closed
PeterVoronov opened this issue Mar 7, 2021 · 2 comments
Labels

Comments

@PeterVoronov
Copy link
Contributor

PeterVoronov commented Mar 7, 2021

Describe the bug
I can't format date & time to string with toLocaleString

To Reproduce
Steps to reproduce the behavior:

  1. Create a script:
let date = new Date(2014, 11, 31, 12, 30, 0);

let formatter = new Intl.DateTimeFormat("ru");
log( 'date in ru : ' + formatter.format(date) ); // 31.12.2014

formatter = new Intl.DateTimeFormat("en-US");
log( 'date in en : ' + formatter.format(date) ); // 12/31/2014
let Now = new Date;
log( 'datetime in ru ' + Now.toLocaleString('ru-RU'));
log( 'datetime in de ' + Now.toLocaleString('de-DE'));
log( 'datetime in en ' + Now.toLocaleString('en-US'));
  1. Run script
  2. Scroll down to /opt/iobroker/log/iobroker.current.log
  3. See the identical strings, as I see it:
2021-03-07 17:14:14.242  - .[32minfo.[39m: javascript.0 (28025) script.js.Test.testLocale: date in ru : 12/31/2014
2021-03-07 17:14:14.244  - .[32minfo.[39m: javascript.0 (28025) script.js.Test.testLocale: date in en : 12/31/2014
2021-03-07 17:14:14.245  - .[32minfo.[39m: javascript.0 (28025) script.js.Test.testLocale: datetime in ru 3/7/2021, 5:14:14 PM
2021-03-07 17:14:14.247  - .[32minfo.[39m: javascript.0 (28025) script.js.Test.testLocale: datetime in de 3/7/2021, 5:14:14 PM
2021-03-07 17:14:14.248  - .[32minfo.[39m: javascript.0 (28025) script.js.Test.testLocale: datetime in en 3/7/2021, 5:14:14 PM

Expected behavior
For date in ru expected - 31.12.2014.
For date in en expected - 12/31/2014.

Screenshots & Logfiles
I think it is not needed

Versions:

  • Adapter version: 4.11.00
  • JS-Controller version: 3.2.16
  • Node version: v12.21.0
  • Operating system: debian buster

Additional context
Add any other context about the problem here.

@PeterVoronov PeterVoronov changed the title localisation is not worked, at least for date & time related functions manual localisation is not worked, at least for date & time related functions Mar 7, 2021
@GermanBluefox
Copy link
Contributor

First of all I would say that it is node.js issue (please notice, that node.js and browser js are not the same)
E.g. nodejs/node#13907

@PeterVoronov
Copy link
Contributor Author

Thanks.

npm -i full-icu

and then

systemctl edit iobroker.service

with

[Service]
Environment="NODE_ICU_DATA=/opt/iobroker/node_modules/full-icu"

solve the issue for me.
Thanks for the route in right direction .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants