fix. UTC 시간 표기 오류 수정
This commit is contained in:
@@ -30,7 +30,10 @@
|
||||
{{ tm('Inspection_Maintenance_Time') }}
|
||||
</h2>
|
||||
<div class="inspection-time text-sm md:text-base font-medium">
|
||||
<div v-dompurify-html="getLocaleTimezone" class="time-row"></div>
|
||||
<div
|
||||
v-dompurify-html="getLocaleTimezone()"
|
||||
class="time-row"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -143,40 +146,46 @@ await getInspectionDataExternal({
|
||||
gameId: gameId.value,
|
||||
})
|
||||
|
||||
// locale에 따라 뒤에 KST 또는 UTC 추가 ko, en, zh-tw, ja
|
||||
// ko: (KST)
|
||||
// en: (UTC)
|
||||
// zh-tw: 台灣時間 (KST)
|
||||
// ja: (JST)
|
||||
// 나머지: (KST)
|
||||
const TIMEZONE_MAP: Record<string, string> = {
|
||||
ko: 'KST',
|
||||
en: 'UTC',
|
||||
ja: 'JST',
|
||||
'zh-tw': '台灣時間',
|
||||
'zh-cn': 'CST',
|
||||
th: 'ICT',
|
||||
}
|
||||
const DEFAULT_TIMEZONE = 'KST'
|
||||
|
||||
const formatInspectionDate = (date: number | Date) => {
|
||||
const currentLocale = locale.value
|
||||
const nation = currentLocale === 'ko' ? 'KR' : ''
|
||||
return `${globalDateFormat(date, currentLocale, nation, { useFullDate: true })}`
|
||||
}
|
||||
|
||||
const formatInspectionUtc = (date: number) =>
|
||||
`${globalDateFormat(date, 'en', '', {
|
||||
useFullDate: true,
|
||||
useUtc: true,
|
||||
})}`
|
||||
|
||||
// locale에 따라 뒤에 KST 또는 UTC 등을 추가
|
||||
const getLocaleTimezone = () => {
|
||||
const tsStartDate = webInspectionData.value?.ts_start_date || 0
|
||||
const tsEndDate = webInspectionData.value?.ts_end_date || 0
|
||||
const currentLocale = locale.value
|
||||
const timezone = TIMEZONE_MAP[currentLocale] ?? DEFAULT_TIMEZONE
|
||||
|
||||
const timezoneMap: Record<string, string> = {
|
||||
ko: 'KST',
|
||||
en: 'UTC',
|
||||
ja: 'JST',
|
||||
'zh-tw': '台灣時間',
|
||||
'zh-cn': 'CST',
|
||||
th: 'ICT',
|
||||
}
|
||||
const timezone = timezoneMap[currentLocale] || 'KST'
|
||||
const defaultRegion = currentLocale === 'ko' ? 'KR' : ''
|
||||
const localTime = `${formatInspectionDate(
|
||||
new Date(tsStartDate)
|
||||
)} <br class="md:hidden">~ ${formatInspectionDate(
|
||||
new Date(tsEndDate)
|
||||
)} (${timezone})`
|
||||
|
||||
const formatDate = (
|
||||
date: Date,
|
||||
loc: string,
|
||||
reg: string,
|
||||
{ useUtc }: { useUtc: boolean } = { useUtc: false }
|
||||
) =>
|
||||
`${globalDateFormat(date, loc, reg || defaultRegion, { useFullDate: true, useUtc: useUtc })}`
|
||||
const utcTime = `${formatInspectionUtc(
|
||||
tsStartDate
|
||||
)} <br class="md:hidden">~ ${formatInspectionUtc(tsEndDate)} (UTC)`
|
||||
|
||||
const localTime = `${formatDate(new Date(tsStartDate), currentLocale, '')} <br class="md:hidden">~ ${formatDate(new Date(tsEndDate), currentLocale, '')} (${timezone})`
|
||||
const utcTime = `${formatDate(new Date(tsStartDate), 'en', '', { useUtc: true })} <br class="md:hidden">~ ${formatDate(new Date(tsEndDate), 'en', '', { useUtc: true })} (UTC)`
|
||||
|
||||
return currentLocale === 'en' ? utcTime : `${localTime}<br>${utcTime}`
|
||||
return currentLocale === 'en' ? localTime : `${localTime}<br>${utcTime}`
|
||||
}
|
||||
|
||||
const launchingStatus = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user