Moment-timezone: Brazil-America/Sao_Paulo datetime offset problem (they don't use DST anymore)

Created on 7 Oct 2019  路  7Comments  路  Source: moment/moment-timezone

According to https://www.timeanddate.com/time/change/brazil?year=2019 Brazil does not use the DST from the beginning of 2019.
I'm using the version 0.5.13 and it seems that the timezone offset is still changed based on DST this October.

When will the timezone for Brazil be changed?

Most helpful comment

1) please ensure that you're using moment-timezone version 0.5.26 or later
2) see how it works:

console.log(moment(`2018-11-18`).tz("America/Sao_Paulo").format());
// returns 2018-11-17T20:00:00-02:00
console.log(moment(`2019-11-18`).tz("America/Sao_Paulo").format());
// returns 2019-11-17T19:00:00-03:00 - because no DST change anymore
console.log(moment(`2020-11-18`).tz("America/Sao_Paulo").format());
// returns 2020-11-17T19:00:00-03:00  - because no DST change anymore

All 7 comments

The data that is used by moment-timezone is from the official time zones database that IANA manages: https://www.iana.org/time-zones

They will need to update their data for it to be fixed in moment-timezone

@ssherman this data is up to date in IANA db:

https://github.com/eggert/tz/commit/8d1bcf9425ead6fd3447a658b20a8bb8a385228d#diff-109e03a0a154807a82e70bef80657ebb

also several threads in their mailing list:
https://mm.icann.org/pipermail/tz/2019-April/

this seems to be working fine for me. I wrote a little test file:
https://gist.github.com/ssherman/6da636c64eb2905d7abef6c9a35cfa96

you can see that the dates switch from daylight savings to normal time on Feb 16th, 2019
2019-02-16T23:00:00-02:00
2019-02-16T23:00:00-03:00

and you can see that in 2020, there is no daylight savings. The offset stays 03:00.

1) please ensure that you're using moment-timezone version 0.5.26 or later
2) see how it works:

console.log(moment(`2018-11-18`).tz("America/Sao_Paulo").format());
// returns 2018-11-17T20:00:00-02:00
console.log(moment(`2019-11-18`).tz("America/Sao_Paulo").format());
// returns 2019-11-17T19:00:00-03:00 - because no DST change anymore
console.log(moment(`2020-11-18`).tz("America/Sao_Paulo").format());
// returns 2020-11-17T19:00:00-03:00  - because no DST change anymore

@ellenaua it's not working for me.

I'm using:
moment-timezone: 0.5.27
console.log(moment('2019-11-20').tz("America/Sao_Paulo").format())

but it returns 2019-11-20T19:00:00-02:00

Even in the chrome's devtools console of moment-timezone website this doesn't work, I can't figure out why tho.

@dotpegaso Did you manage to get this working? Im experiencing this issue too.

"moment-timezone": "^0.5.27"

@dotpegaso Did you manage to get this working? Im experiencing this issue too.

"moment-timezone": "^0.5.27"

I did using react-native-v8. Just follow the readme, very straightforward.

Was this page helpful?
0 / 5 - 0 ratings