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

Consistent Timezone Abbreviations #5002

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps-rendering/src/date.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ describe('fromString', () => {
describe('formatLocal', () => {
test('returns correct local time zone (local timezone is Europe/London set in TZ global variable)', () => {
expect(formatLocal(new Date('2020-03-11T17:25:00'))).toBe(
'Wed 11 Mar 2020 17.25 (Greenwich Mean Time)',
'Wed 11 Mar 2020 17.25 GMT',
);
});

test('returns Europe/London local time for non UTC time', () => {
expect(formatLocal(new Date('2012/02/10 10:10:30 +0180'))).toBe(
'Fri 10 Feb 2012 07.50 (Greenwich Mean Time)',
'Fri 10 Feb 2012 07.50 GMT',
);
});
});
Expand Down
5 changes: 1 addition & 4 deletions apps-rendering/src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ const localTime12Hr = (date: Date): string =>
.replace(':', '.')
.toLowerCase();

const localTimeZone = (date: Date): string =>
/\(.*?\)$/.exec(date.toTimeString())?.pop() ?? '';

const localTimeZoneAbbr = (date: Date): string =>
/([^\s]+)$/
.exec(date.toLocaleString([], { timeZoneName: 'short' }))
Expand All @@ -176,7 +173,7 @@ const fullyFormat = (date: Date): string =>
const formatLocal = (date: Date): string =>
`${localDay(date)} ${date.getDate()} ${localMonth(
date,
)} ${date.getFullYear()} ${localTime(date)} ${localTimeZone(date)}`;
)} ${date.getFullYear()} ${localTime(date)} ${localTimeZoneAbbr(date)}`;

const formatLocalTimeDateTz = (date: Date): string =>
`${localTime12Hr(date)} ${date.getDate()} ${localMonth(
Expand Down