|
@@ -2,7 +2,7 @@ import { View, Text } from '@tarojs/components'
|
|
|
import '@/features/trackTimeDuration/components/CircadianDetailPopup.scss'
|
|
import '@/features/trackTimeDuration/components/CircadianDetailPopup.scss'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
import { useEffect, useState } from 'react'
|
|
import { useEffect, useState } from 'react'
|
|
|
-import { rpxToPx } from '@/utils/tools'
|
|
|
|
|
|
|
+import { getTimezone, getTimezoneName, rpxToPx } from '@/utils/tools'
|
|
|
import { TimeFormatter } from '@/utils/time_format'
|
|
import { TimeFormatter } from '@/utils/time_format'
|
|
|
import { useSelector } from 'react-redux'
|
|
import { useSelector } from 'react-redux'
|
|
|
import { ColorType } from '@/context/themes/color'
|
|
import { ColorType } from '@/context/themes/color'
|
|
@@ -471,6 +471,44 @@ export default function DayNightDetailPopup(props: {
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function getTZLocation() {
|
|
|
|
|
+ var name = props.authInfo.timezone
|
|
|
|
|
+ if (props.authInfo.timezone_name) {
|
|
|
|
|
+ name = `${name} (${props.authInfo.timezone_name})`
|
|
|
|
|
+ }
|
|
|
|
|
+ return name
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getDeviceLocation() {
|
|
|
|
|
+ return `${getTimezone()} (${getTimezoneName()})`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getTZOffset() {
|
|
|
|
|
+ var current1 = dayjs()
|
|
|
|
|
+ var current = dayjs().tz(props.authInfo.timezone_id)
|
|
|
|
|
+ var offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
|
|
|
|
|
+
|
|
|
|
|
+ var hour = Math.floor(Math.abs(offset) / 60)
|
|
|
|
|
+ var minute = Math.abs(offset) % 60
|
|
|
|
|
+ var time = ''
|
|
|
|
|
+ if (global.language == 'en') {
|
|
|
|
|
+ time = `${hour} h`
|
|
|
|
|
+ if (minute > 0) {
|
|
|
|
|
+ time += ` ${minute} m`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ time = `${hour}小时`
|
|
|
|
|
+ if (minute > 0) {
|
|
|
|
|
+ time += `${minute}分钟`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return offset > 0 ? t('feature.day_night.ahead_desc', { time: time }) : t('feature.day_night.behind_desc', { time: time })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function diffentTZDesc() {
|
|
function diffentTZDesc() {
|
|
|
var current1 = dayjs()
|
|
var current1 = dayjs()
|
|
|
var current = dayjs().tz(props.authInfo.timezone_id)
|
|
var current = dayjs().tz(props.authInfo.timezone_id)
|
|
@@ -495,9 +533,12 @@ export default function DayNightDetailPopup(props: {
|
|
|
time += `${minute}分钟`
|
|
time += `${minute}分钟`
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return t('feature.day_night.diff_tz_desc', { location: props.authInfo.timezone_id, time: time, type: type })
|
|
|
|
|
|
|
+ return t('feature.common.diff_tz_desc', { location: getTZLocation(), device_location: getDeviceLocation(), offset: getTZOffset() })
|
|
|
|
|
+ // return t('feature.common.diff_tz_desc', { location: props.authInfo.timezone_id, time: time, type: type })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
function getLocation() {
|
|
function getLocation() {
|
|
|
var city = ''
|
|
var city = ''
|
|
|
if ((props.authInfo as any).address) {
|
|
if ((props.authInfo as any).address) {
|
|
@@ -539,7 +580,7 @@ export default function DayNightDetailPopup(props: {
|
|
|
showCancel: true,
|
|
showCancel: true,
|
|
|
cancelText: t('feature.day_night.later'),
|
|
cancelText: t('feature.day_night.later'),
|
|
|
confirmText: t('feature.day_night.picker_now'),
|
|
confirmText: t('feature.day_night.picker_now'),
|
|
|
- confirm:()=>{
|
|
|
|
|
|
|
+ confirm: () => {
|
|
|
props.updateLocation()
|
|
props.updateLocation()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|