Skip to content

Commit 7d160ca

Browse files
committed
feat(date-timezone): dynamically generate timezone list using moment-timezone
Signed-off-by: Manuel Abascal <mjabascal10@gmail.com>
1 parent 52736eb commit 7d160ca

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

frontend/src/app/shared/constants/date-timezone-date.const.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import moment from 'moment-timezone';
2+
13
export const DATE_SECTION_ID = 5;
24

35
export const DEFAULT_DATE_SETTING_TIMEZONE = 'UTC';
@@ -6,7 +8,19 @@ export const DEFAULT_DATE_SETTING_DATE = 'medium';
68
export const DATE_SETTING_TIMEZONE_SHORT = 'utmstack.time.zone';
79
export const DATE_SETTING_FORMAT_SHORT = 'utmstack.time.dateformat';
810

9-
export const TIMEZONES: Array<{ label: string; timezone: string, zone: string }> = [
11+
export const TIMEZONES: Array<{ label: string; timezone: string; zone: string }> =
12+
moment.tz.names().map((tz) => {
13+
const parts = tz.split('/');
14+
const zone = parts[0] || 'Other';
15+
const label = tz.replace(/_/g, ' ');
16+
return {
17+
label,
18+
timezone: tz,
19+
zone
20+
};
21+
});
22+
23+
/*export const TIMEZONES: Array<{ label: string; timezone: string, zone: string }> = [
1024
{label: 'UTC', timezone: 'UTC', zone: 'UTC'},
1125
{label: 'Eastern Standard Time (New York)', timezone: 'America/New_York', zone: 'America'},
1226
{label: 'Pacific Standard Time (Los Angeles)', timezone: 'America/Los_Angeles', zone: 'America'},
@@ -38,7 +52,7 @@ export const TIMEZONES: Array<{ label: string; timezone: string, zone: string }>
3852
{label: 'Jerusalem (IST)', timezone: 'Asia/Jerusalem', zone: 'Asia'},
3953
{label: 'Buenos Aires (ART)', timezone: 'America/Argentina/Buenos_Aires', zone: 'America'},
4054
{label: 'São Paulo (BRT)', timezone: 'America/Sao_Paulo', zone: 'America'},
41-
];
55+
];*/
4256

4357
export const DATE_FORMATS: Array<{ label: string; format: string; equivalentTo: string }> = [
4458
{label: 'Short', format: 'short', equivalentTo: 'M/d/yy, h:mm a'},

0 commit comments

Comments
 (0)