You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NodeJS reports incorrect time zone for Brazil #30211
Platform: Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019
Subsystem: N/A
Node is reporting the wrong time zone for Brazil after its cancelled daylight savings change on November 2.
Reproduction:
var process = require('process');
console.log('ICU version: ' + process.versions.icu);
var options = {
timeZone: "America/Sao_Paulo",
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
timeZoneName: 'short'
};
var formatter = new Intl.DateTimeFormat([], options);
var UTCTimeBefore = new Date(new Date().toUTCString());
var UTCTimeAfter = new Date(UTCTimeBefore.getTime() + (7 * 24 * 60 * 60 * 1000));
var UTCTimeAfter = new Date(UTCTimeBefore.getTime() + (30 * 24 * 60 * 60 * 1000));
var localTime = formatter.format(UTCTimeBefore);
console.log('Should be GMT-3')
console.log(localTime);
var localTime = formatter.format(UTCTimeAfter);
console.log('Should also be GMT-3')
console.log(localTime);
Outputs:
ICU version: 64.2
Should be GMT-3
11/1/2019, 7:19:15 PM GMT-3
Should also be GMT-3
12/1/2019, 8:19:15 PM GMT-2
I believe this is because node v13.0.1 depends on ICU version 64.2 which includes tzdata 2019a. However, brazil's updated daylight savings was added in tzdata 2019b, which requires a minimum ICU version of 65.1.
Time zone data files are updated independently of ICU. You do not need to tie updating time zone data with upgrading ICU, which could have other consequences.
If it helps, the shasum of the v12.13.0 release and patched files:
Release: 2b681d53f193f714db86b038176da6866f8d5afd icudt64l.dat
Patched: 7317c1d424812d9ef1ed318e70db7ed27b93853c icudt64l.dat
Reacted by Steven R. Loomis, Anderson Dapper Rocha, Albert Wang and Daniel Lopes
@apaprocki would you like to make a PR to update tools/icu/ with a readme about how to do this? Good instructions. I would add that you can have the updated tz data outside of node.js, without recompiling, i will have to add detailed instructions for that.
additionally, process.versions.tz will return the tz version such as 2019b
I would add that you can have the updated tz data outside of node.js, without recompiling, i will have to add detailed instructions for that.
I specifically left that part out because Node does not currently build with the external directory enabled. If someone decides on an installation path where Node should look for updated ICU time zone data files, I can include that text as well. (e.g., PREFIX/share/icu/tzdata?)
Also, current ICU (65.1) does not expose the ..._ENV_VAR override for the external time zone resource directory the same way that it does for the whole ICU data file directory. I had to add patch in support for that to ICU to make it so that both data file directories could be properly relocatable with the same (in my case) environment variable. I'll look into sending that patch upstream.
I have the same problem, I need to set the time zone for the America/Campo_Grande node, I already changed the environment variable (TZ) but it still doesn't work ...
@kirliam@leonetosoft is this on Windows? That seems to be the only place it would make a difference, all set-tz does is set process.env.TZ besides on Windows.
Edit: i misread, set-tz may not even do that. Can you show me some code that isn't working and tell me the version and OS?
Activity
targos commentedon Nov 1, 2019
Tracking issue for update to ICU 65.1: #29540
apaprocki commentedon Nov 10, 2019
Time zone data files are updated independently of ICU. You do not need to tie updating time zone data with upgrading ICU, which could have other consequences.
To update the existing ICU 64
.datfile:lelittle-endian, andbebig-endian, depending on platform).datfile for all four time zone resource files (the resource files must be in the current directory):.datfile using the-llist option-xextract the file, theshasummatches what you intended to patchTo test the patched file works...
Existing Node v12.13.0 release:
After patching
.datfile:If it helps, the
shasumof the v12.13.0 release and patched files:Release: 2b681d53f193f714db86b038176da6866f8d5afd icudt64l.dat
Patched: 7317c1d424812d9ef1ed318e70db7ed27b93853c icudt64l.dat
MylesBorins commentedon Nov 10, 2019
/cc @srl295
srl295 commentedon Nov 11, 2019
@apaprocki would you like to make a PR to update
tools/icu/with a readme about how to do this? Good instructions. I would add that you can have the updated tz data outside of node.js, without recompiling, i will have to add detailed instructions for that.additionally,
process.versions.tzwill return the tz version such as2019bapaprocki commentedon Nov 12, 2019
I specifically left that part out because Node does not currently build with the external directory enabled. If someone decides on an installation path where Node should look for updated ICU time zone data files, I can include that text as well. (e.g.,
PREFIX/share/icu/tzdata?)Also, current ICU (65.1) does not expose the
..._ENV_VARoverride for the external time zone resource directory the same way that it does for the whole ICU data file directory. I had to add patch in support for that to ICU to make it so that both data file directories could be properly relocatable with the same (in my case) environment variable. I'll look into sending that patch upstream.srl295 commentedon Nov 12, 2019
apaprocki commentedon Nov 12, 2019
@srl295 I filed ICU-20895 and opened the pull request for the environment variable.
tools: update tzdata to 2019c
19 remaining items
tools: update icu to 65.1
tools: update icu to 65.1
tools: update icu to 65.1
leonetosoft commentedon May 7, 2020
I have the same problem, I need to set the time zone for the America/Campo_Grande node, I already changed the environment variable (TZ) but it still doesn't work ...
kirliam commentedon May 7, 2020
@leonetosoft I had the same problem, and the workaround I'm using is the "set-tz" package. Install it and add in the first lines of your app:
const setTZ = require('set-tz');
setTZ('America/Bahia');
srl295 commentedon May 7, 2020
@kirliam @leonetosoft is this on Windows? That seems to be the only place it would make a difference, all set-tz does is set process.env.TZ besides on Windows.
Edit: i misread, set-tz may not even do that. Can you show me some code that isn't working and tell me the version and OS?
emarcelino3 commentedon May 13, 2020
I substitute timeZone: "America/Sao_Paulo" by timeZone: "-03:00".
work fine to me
kirliam commentedon May 13, 2020
doc: document ICU time zone data update process
doc: document ICU time zone data update process