알림목록 obv 그래프 문제 최종수정
This commit is contained in:
@@ -73,6 +73,31 @@ export function getTimezoneAbbr(tz: string): string {
|
||||
return TIMEZONE_OPTIONS.find(o => o.id === id)?.abbr ?? id.split('/').pop() ?? 'TZ';
|
||||
}
|
||||
|
||||
/**
|
||||
* 주어진 시각의 표시 시간대 오프셋(초). 벽시계 정시 경계 정렬에 사용.
|
||||
* (예: Asia/Seoul → +32400)
|
||||
*/
|
||||
export function getTimezoneOffsetSec(unixSec: number, tz?: string): number {
|
||||
const zone = normalizeTimezone(tz ?? _tz);
|
||||
const parts = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: zone,
|
||||
year: 'numeric', month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit', second: '2-digit',
|
||||
hour12: false,
|
||||
}).formatToParts(new Date(unixSec * 1000));
|
||||
const map: Record<string, string> = {};
|
||||
for (const p of parts) {
|
||||
if (p.type !== 'literal') map[p.type] = p.value;
|
||||
}
|
||||
let hour = Number(map.hour);
|
||||
if (hour === 24) hour = 0;
|
||||
const asUTC = Date.UTC(
|
||||
Number(map.year), Number(map.month) - 1, Number(map.day),
|
||||
hour, Number(map.minute), Number(map.second),
|
||||
) / 1000;
|
||||
return asUTC - unixSec;
|
||||
}
|
||||
|
||||
/** 하단 바·시계 등 HH:mm:ss */
|
||||
export function formatUnixClock(unixSec: number, tz?: string, withSeconds = true): string {
|
||||
if (!unixSec) return '–';
|
||||
|
||||
Reference in New Issue
Block a user