moment-timezone
moment-timezone copied to clipboard
Why zone abbreviations got removed
Abbreviations of many time zones are not working In the latest version of moment, abbreviation/short form of many time zones are not working As per https://momentjs.com/timezone/docs/#/using-timezones/formatting/ doc, it should work.
To Reproduce Steps to reproduce the behavior:
- moment.tz('America/Chicago').zoneAbbr() CST (working)
- moment.tz('America/Sao_Paulo').zoneAbbr() -03 (not working, it supposed to be BRT)
- or moment().tz('America/Sao_Paulo').format('z') also giving -03
Analysis In file node_modules/moment-timezone/data/packed/latest.json grep "America/Sao_Paulo" node_modules/moment-timezone/data/packed/latest.json As per my understanding issue is with line "America/Sao_Paulo|LMT -03 -02|36.s 30 20....." It supposed to be "America/Sao_Paulo|LMT BRT BRST|36.s 30 20....."
Please guide me
I have the same question as above and have found these timezone abbreviations are missing as well:
America/Sao_Paulo : -03 Asia/Bangkok : +07 Asia/Dhaka : +06 Asia/Dubai : +04 Atlantic/Cape_Verde : -01 Atlantic/South_Georgia : -02 Pacific/Pohnpei : +11
This comes from the underlying data source: the IANA time zone database. Many years ago, the database maintainers invented abbreviations for time zones that didn't have a well-defined one in common use. This was later regarded as a mistake, and they've been progressively removing these inventions.
The conversion of America/Sao_Paulo
to display -03
happened in data release 2017a: https://mm.icann.org/pipermail/tz-announce/2017-February/000045.html
Switch to numeric time zone abbreviations for South America, as part of the ongoing project of removing invented abbreviations. This avoids the need to invent an abbreviation for the new Chilean new zone. Similarly, switch from invented to numeric time zone abbreviations for Afghanistan, American Samoa, the Azores, Bangladesh, Bhutan, the British Indian Ocean Territory, Brunei, Cape Verde, Chatham Is, Christmas I, Cocos (Keeling) Is, Cook Is, Dubai, East Timor, Eucla, Fiji, French Polynesia, Greenland, Indochina, Iran, Iraq, Kiribati, Lord Howe, Macquarie, Malaysia, the Maldives, Marshall Is, Mauritius, Micronesia, Mongolia, Myanmar, Nauru, Nepal, New Caledonia, Niue, Norfolk I, Palau, Papua New Guinea, the Philippines, Pitcairn, Qatar, Réunion, St Pierre & Miquelon, Samoa, Saudi Arabia, Seychelles, Singapore, Solomon Is, Tokelau, Tuvalu, Wake, Vanuatu, Wallis & Futuna, and Xinjiang; for 20-minute daylight saving time in Ghana before 1943; for half-hour daylight saving time in Belize before 1944 and in the Dominican Republic before 1975; and for Canary Islands before 1946, for Guinea-Bissau before 1975, for Iceland before 1969, for Indian Summer Time before 1942, for Indonesia before around 1964, for Kenya before 1960, for Liberia before 1973, for Madeira before 1967, for Namibia before 1943, for the Netherlands in 1937-9, for Pakistan before 1971, for Western Sahara before 1977, and for Zaporozhye in 1880-1924.
This can also been seen in other systems using the same data. For example, on the command line in macOS:
$ TZ=America/Chicago date
Wed 20 May 2020 07:11:04 CDT
$ TZ=America/Sao_Paulo date
Wed 20 May 2020 09:11:04 -03
Also, note that these cases are mentioned in the momentjs documentation you linked to:
Please note that the
z
formatting token will not always show the abbreviated time zone name, instead, will show the time offsets for each region.
My question then is how do we remedy this? Do you provide a work around for this?
Considering some people would prefer the old behavior, it seems maybe there should be an option to retrieve the string abbreviation but the numeric one would be served as default?
@diegodesouza @monsonjeremy the one true way to remedy the situation is to persuade IANA that their "invented" offset abbreviations actually stuck in peoples minds and they want them back.
moment-timezone is not positioned itself to diverge from the official tzdata used by all libraries, languages and OSes out there. If you feel like you can handle that, just add a plugin that maintains "obsolete" offsets and enriches output of moment-timezone.