iamkun / iamkun/dayjs

GMT 0 timezones don't work when locale is set

Open
#2,545 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

GMT 0 timezones don't work when locale is set

`dayjs($now).tz('Etc/GMT').locale( 'en').format('h:mm A')`

> INCORRECT time: `1:36pm`

`dayjs($now).tz('Etc/GMT').format('h:mm A')` (without `locale`)

> CORRECT time: `5:36pm`

This bug is only present if the timezone is 'Etc/GMT' (or 'Europe/London') and works fine in 'Etc/GMT+1' and 'Etc/GMT-1' with locale set.

**Expected behavior**

The correct time should be shown when `tz` is set to `GMT` and `locale` is set to `en`

**Information**
- Dayjs 1.11.10
- Windows 10
- Chrome Version 120.0.6099.130 (Official Build) (64-bit)
- Time zone: `Etc/GMT` (aka `Europe/London`)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two reported Day.js expressions with the timezone and locale combinations named in the issue, comparing Etc/GMT and Europe/London with Etc/GMT+1 and Etc/GMT-1. Trace the timezone and locale formatting entry points to identify the discrepancy, then verify that GMT 0 zones produce the correct formatted time without regressing the other examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
localization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.