|
|
@@ -1,10 +1,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { useRouter } from 'vue-router'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import tz from 'dayjs/plugin/timezone'
|
|
|
-import utc from 'dayjs/plugin/utc'
|
|
|
-dayjs.extend(utc)
|
|
|
-dayjs.extend(tz)
|
|
|
+import { formatTimezone } from '@/utils/tools'
|
|
|
|
|
|
const router = useRouter()
|
|
|
interface RecentItem {
|
|
|
@@ -37,22 +34,6 @@ const RouteToDetail = (val: any) => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-const formatDate = (date: string, zone: any) => {
|
|
|
- if (!date) return '--'
|
|
|
- let formattedTime = ''
|
|
|
- formattedTime = dayjs(date).format('MMM-DD-YYYY hh:mm A')
|
|
|
- let gmtOffset = ''
|
|
|
- if (zone && zone.length > 3) {
|
|
|
- // 替换 "+07:00" 为 "GMT+7"
|
|
|
- const timeZoneOffset = dayjs().tz(zone).format('Z')
|
|
|
- if (zone.includes('Seoul')) {
|
|
|
- gmtOffset = `(UTC${timeZoneOffset.slice(0, 3)})`
|
|
|
- } else {
|
|
|
- gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
|
|
|
- }
|
|
|
- }
|
|
|
- return `${formattedTime} ${gmtOffset}`
|
|
|
-}
|
|
|
</script>
|
|
|
<template>
|
|
|
<div class="recent_route" v-for="(item, index) in props.RecentStatusList" :key="index">
|
|
|
@@ -143,7 +124,7 @@ const formatDate = (date: string, zone: any) => {
|
|
|
<VTag :type="item.type" style="margin-bottom: 4px">{{ item.type }}</VTag>
|
|
|
<div class="right_text">{{ item.Arrived }}</div>
|
|
|
<div class="startStation_time" v-if="item.Time != null">
|
|
|
- {{ formatDate(item.Time, item.timezone) }} {{ item.timezone }}
|
|
|
+ {{ formatTimezone(item.Time, item.timezone) }} {{ item.timezone }}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|