iamkun / iamkun/dayjs

Missing am/pm notation in en-gb locale for time-based localized formats

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

Description

All of the time based Localized formats for `en-gb` are missing the `a` template token, and therefore all of the outputs are missing "am" or "pm" notations.

Here are some authoritative resources saying that UK time (i.e. `en-gb` locale) should have lowercase "am" or "pm" notation:
- [Wikipedia: Date and time notation in the United Kingdom](https://en.wikipedia.org/wiki/Date_and_time_notation_in_the_United_Kingdom)
- [Oxford University Style Guide](https://www.ox.ac.uk/sites/files/oxford/media_wysiwyg/University%20of%20Oxford%20Style%20Guide.pdf)
- [The Guardian Style Guide](https://www.theguardian.com/guardian-observer-style-guide-t)

As shown below, this is not currently happening:

```TypeScript
import dayjs from "dayjs";
import localizedFormat from "dayjs/plugin/localizedFormat";
import "dayjs/locale/en-gb";

dayjs.extend(localizedFormat);
dayjs.locale("en-gb");

console.log(dayjs().format("LT"));
// Current output: 12:28
// Correct output: 12:28 pm

console.log(dayjs().format("LTS"));
// Current output: 12:29:44
// Correct output: 12:29:44 pm

console.log(dayjs().format("LLL"));
// Current output: 28 October 2023 12:29
// Correct output: 28 October 2023 12:29 pm

console.log(dayjs().format("LLLL"));
// Current output: Saturday, 28 October 2023 12:29
// Correct output: Saturday, 28 October 2023 12:29 pm

console.log(dayjs().format("lll"));
// Current output: 28 Oct 2023 12:29
// Correct output: 28 Oct 2023 12:29 pm

console.log(dayjs().format("llll"));
// Current output: Sat, 28 Oct 2023 12:29
// Correct output: Sat, 28 Oct 2023 12:29 pm
```

I'm not 100% sure, but I think to fix this issue this file should be updated: https://github.com/iamkun/dayjs/blob/dev/src/locale/en-gb.js

Current code:

```JavaScript
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
```

Suggested update to fix the problem:

```JavaScript
formats: {
LT: 'HH:mm a',
LTS: 'HH:mm:ss a',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm a',
LLLL: 'dddd, D MMMM YYYY HH:mm a'
},
```

**Information**
- Day.js Version 1.11.10
- OS: MacOS
- Browser: Brave 1.58.137
- Time zone: GMT+07:00

Contributor guide

Open the contributing guide

Research direction

Start with src/locale/en-gb.js and inspect the localized formats used by the localizedFormat plugin. Reproduce the reported LT, LTS, LLL, LLLL, lll, and llll outputs, then update the locale formats so they include the requested lowercase am/pm notation. Verify that the outputs match the examples in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
localization
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.