11<script setup lang="ts">
2- import { ref } from " vue"
2+ import { computed , ref } from " vue"
33import useTimePositionMapping from " ../composables/useTimePositionMapping"
44import dayjs from " dayjs"
55import provideConfig from " ../provider/provideConfig"
@@ -8,15 +8,23 @@ import { useIntervalFn } from "@vueuse/core"
88
99const { mapTimeToPosition } = useTimePositionMapping ()
1010const currentMoment = ref (dayjs ())
11- const { colors, dateFormat, currentTimeLabel } = provideConfig ()
11+ const { colors, dateFormat, currentTimeLabel, utc } = provideConfig ()
1212const xDist = ref ()
1313
1414const loopTime = () => {
15- currentMoment .value = dayjs ()
15+ const now = utc .value ? dayjs ().utc () : dayjs ()
16+ currentMoment .value = now
1617 const format = dateFormat .value || " YYYY-MM-DD HH:mm:ss"
1718 xDist .value = mapTimeToPosition (dayjs (currentMoment .value , format ).format (format ))
1819}
1920useIntervalFn (loopTime , 1000 )
21+
22+ const currentTimeDisplay = computed (() => {
23+ if (utc .value ) {
24+ return ` ${currentTimeLabel .value } (UTC) `
25+ }
26+ return currentTimeLabel .value
27+ })
2028 </script >
2129
2230<template >
@@ -34,7 +42,7 @@ useIntervalFn(loopTime, 1000)
3442 />
3543 <span class =" g-grid-current-time-text" :style =" { color: colors.markerCurrentTime }" >
3644 <slot name =" current-time-label" >
37- {{ currentTimeLabel }}
45+ {{ currentTimeDisplay }}
3846 </slot >
3947 </span >
4048 </div >
0 commit comments