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

Format issue: wrong timezone name #1117

Open
AlimovSV opened this issue Sep 20, 2024 · 2 comments
Open

Format issue: wrong timezone name #1117

AlimovSV opened this issue Sep 20, 2024 · 2 comments

Comments

@AlimovSV
Copy link

Environment

{
  moment: '2.30.1',
  momentTz: '0.5.45',
  date: 'Fri Sep 20 2024 15:50:16 GMT+0400 (Самарское стандартное время)',
  intlZone: 'Europe/Samara'
}

Issue description

>  moment.updateLocale('en-au')
...
>  moment('2023-04-17T20:47:08.962599+08:45').tz('Australia/Eucla').format('lll z')
'Apr 17, 2023 8:47 PM +0845'

formatted zone name is +0845 but expected ACWST

> Intl.DateTimeFormat("en-AU", {
...   timeZone: "Australia/Eucla",
...   day: "numeric",
...   month: "short",
...   year: "numeric",
...   hour: "numeric",
...   minute: "numeric",
...   timeZoneName: "short"
... }).format(new Date('2023-04-17T20:47:08.962599+08:45'))
'17 Apr 2023, 8:47 pm ACWST'

Looks like the problem is in the timezone definitions:

{
  name: 'Australia/Eucla',
  abbrs: [
    'LMT',   '+0845', '+0945',
    '+0845', '+0945', '+0845',
    '+0945', '+0845', '+0945',
    '+0845', '+0945', '+0845',
    '+0945', '+0845', '+0945',
    '+0845', '+0945', '+0845',
    '+0945', '+0845'
  ],
  untils: [
    -2337928528000, -1672555500000,
    -1665384300000,  -883637100000,
     -876120300000,  -860395500000,
     -844670700000,   152039700000,
      162926100000,   436295700000,
      447182100000,   690311700000,
      699383700000,  1165079700000,
     1174756500000,  1193505300000,
     1206810900000,  1224954900000,
     1238260500000,       Infinity
  ],
  offsets: [
    -515.4666666666667, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525,
                  -585, -525
  ],
  population: 368
}
@sslincoco
Copy link

sslincoco commented Sep 20, 2024 via email

@gilmoreorless
Copy link
Member

The abbreviation "ACWST" was originally invented by the lead maintainer of the time zone database, and is not actually the real designation of the zone. The Australia/Eucla zone is for a region that isn't officially recognised by the government as having a separate time zone (it's just a bunch of local towns that change their clocks voluntarily), so there isn't any real abbreviation for the zone.

A few years ago, the tzdb maintainers started removing these previously made-up names and replacing them with plain offsets. The change to Australia/Eucla was done in 2017 (eggert/tz@a25d615) and has been in the Moment Timezone data ever since.

Some browsers have chosen to continue using the deprecated, unofficial names for backwards compatibility. That explains why you still see "ACWST" in the Intl.DateTimeFormat result.

I'm going to keep this issue open, as a reminder to add some documentation about these cases. This isn't the first time that users have been confused by the offsets appearing as zone names.

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

No branches or pull requests

3 participants