|
|
@ -10,11 +10,15 @@ export class TimezoneService { |
|
|
protected readonly document = inject(DOCUMENT); |
|
|
protected readonly document = inject(DOCUMENT); |
|
|
private readonly cookieKey = '__timezone'; |
|
|
private readonly cookieKey = '__timezone'; |
|
|
private timeZoneNameFromSettings: string | null | undefined; |
|
|
private timeZoneNameFromSettings: string | null | undefined; |
|
|
|
|
|
public isUtcClockEnabled: boolean | undefined; |
|
|
|
|
|
|
|
|
constructor() { |
|
|
constructor() { |
|
|
this.configState.getOne$('timing').subscribe(timezoneSettings => { |
|
|
this.configState.getOne$('timing').subscribe(timezoneSettings => { |
|
|
this.timeZoneNameFromSettings = timezoneSettings?.timeZone?.iana?.timeZoneName; |
|
|
this.timeZoneNameFromSettings = timezoneSettings?.timeZone?.iana?.timeZoneName; |
|
|
}); |
|
|
}); |
|
|
|
|
|
this.configState.getOne$('clock').subscribe(clock => { |
|
|
|
|
|
this.isUtcClockEnabled = clock?.kind === 'Utc'; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getBrowserTimezone(): string { |
|
|
getBrowserTimezone(): string { |
|
|
@ -27,7 +31,9 @@ export class TimezoneService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setTimezone(timezone: string): void { |
|
|
setTimezone(timezone: string): void { |
|
|
this.document.cookie = `${this.cookieKey}=${timezone}; path=/`; |
|
|
if (this.isUtcClockEnabled) { |
|
|
|
|
|
this.document.cookie = `${this.cookieKey}=${timezone}; path=/`; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
convertUtcToLocal(date: string | Date): Date { |
|
|
convertUtcToLocal(date: string | Date): Date { |
|
|
|