Skip to content

Commit

Permalink
timezone names across all locales
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterHW committed May 13, 2024
1 parent 560179b commit 0eecfb1
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 734 deletions.
7 changes: 4 additions & 3 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ export const formatLocalDateAsISOString = (date: Date): string => {
};

export function getTimezoneName() {
const moment = require('moment-timezone');
const today = new Date();
const short = today.toLocaleDateString(undefined);
const full = today.toLocaleDateString(undefined, { timeZoneName: "short" });
const userTimeZone = moment.tz.guess();
const formattedDate = moment(today).tz(userTimeZone).format('z')

return full.replace(short, "").replace(/[^A-Z]+/g, "");
return formattedDate;
}

export const getLocalTime = (date: Date): string => {
Expand Down
1 change: 1 addition & 0 deletions packages/round-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"moment": "^2.29.3",
"moment-timezone": "^0.5.45",
"os-browserify": "^0.3.0",
"papaparse": "^5.4.1",
"process": "^0.11.10",
Expand Down
Loading

0 comments on commit 0eecfb1

Please sign in to comment.