|
|
@@ -13,10 +13,11 @@ import Taro from "@tarojs/taro";
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
import 'dayjs/locale/zh-cn';
|
|
|
import 'dayjs/locale/en';
|
|
|
+import momentT from 'moment';
|
|
|
|
|
|
import { getTimezone, getTimezoneName } from "@/utils/tools";
|
|
|
|
|
|
-import { AppState } from "react-native";
|
|
|
+import { AppState, SafeAreaView } from "react-native";
|
|
|
// import 'moment/locale/en';
|
|
|
|
|
|
|
|
|
@@ -49,18 +50,18 @@ export default function IndexTimePage() {
|
|
|
setInterval(() => {
|
|
|
setCount(t => t + 1)
|
|
|
const now = new Date()
|
|
|
- const seconds = now.getHours()*3600+now.getMinutes()*60+now.getSeconds()
|
|
|
- if (current && current.time && current.time.timezone.use_dst){
|
|
|
- if (current.time_changes && current.time_changes.length>1){
|
|
|
+ const seconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
|
|
|
+ if (current && current.time && current.time.timezone.use_dst) {
|
|
|
+ if (current.time_changes && current.time_changes.length > 1) {
|
|
|
const date = new Date(current.time_changes[1].timestamp)
|
|
|
- const seconds2 = date.getHours()*3600+date.getMinutes()*60+date.getSeconds()
|
|
|
- if (seconds == seconds2){
|
|
|
+ const seconds2 = date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds()
|
|
|
+ if (seconds == seconds2) {
|
|
|
refresh()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}, 1000)
|
|
|
}, [])
|
|
|
|
|
|
@@ -96,6 +97,12 @@ export default function IndexTimePage() {
|
|
|
i18n.changeLanguage(language)
|
|
|
setIsEn(language == 'en')
|
|
|
dayjs.locale(language == 'en' ? 'en' : 'zh-cn');
|
|
|
+ require('moment/locale/en-gb')
|
|
|
+ require('moment/locale/zh-cn')
|
|
|
+
|
|
|
+ momentT.locale(language == 'en' ? 'en-gb' : 'zh-cn')
|
|
|
+ moment.defineLocale(language == 'en' ? 'en-gb' : 'zh-cn', (momentT.localeData() as any)._config)
|
|
|
+ moment.locale(language == 'en' ? 'en-gb' : 'zh-cn')
|
|
|
// moment.locale(language == 'en' ? 'en' : 'zh-cn');
|
|
|
}
|
|
|
|
|
|
@@ -115,6 +122,13 @@ export default function IndexTimePage() {
|
|
|
Taro.setStorage({ key: 'language', data: isEnglish ? 'en' : 'zh' })
|
|
|
setShowLanguage(false)
|
|
|
dayjs.locale(isEnglish ? 'en' : 'zh-cn');
|
|
|
+
|
|
|
+ require('moment/locale/en-gb')
|
|
|
+ require('moment/locale/zh-cn')
|
|
|
+
|
|
|
+ momentT.locale(isEnglish ? 'en-gb' : 'zh-cn')
|
|
|
+ moment.defineLocale(isEnglish ? 'en-gb' : 'zh-cn', (momentT.localeData() as any)._config)
|
|
|
+ moment.locale(isEnglish ? 'en-gb' : 'zh-cn')
|
|
|
// moment.locale(isEnglish ? 'en' : 'zh-cn');
|
|
|
|
|
|
if (current) {
|
|
|
@@ -199,6 +213,10 @@ export default function IndexTimePage() {
|
|
|
function changeLocation(location) {
|
|
|
setCurrent(location)
|
|
|
Taro.setStorage({ key: 'lastLocation', data: JSON.stringify(location) })
|
|
|
+ chooseLocation({
|
|
|
+ lat: location.geo.lat,
|
|
|
+ lng: location.geo.lng
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function getLocation() {
|
|
|
@@ -209,6 +227,7 @@ export default function IndexTimePage() {
|
|
|
if (current.geo.country) {
|
|
|
return current.geo.country
|
|
|
}
|
|
|
+ return `${Math.abs(parseInt(current.geo.lat))}°${parseInt(current.geo.lat) < 0 ? 'S' : 'N'} ${Math.abs(parseInt(current.geo.lng))}°${parseInt(current.geo.lng) < 0 ? 'W' : 'E'}`
|
|
|
}
|
|
|
return t('time_of_day.index.unknown')
|
|
|
}
|
|
|
@@ -282,19 +301,13 @@ export default function IndexTimePage() {
|
|
|
function languageModalContent() {
|
|
|
return <View className="modal_bg">
|
|
|
<View className="language_content">
|
|
|
- <View className="language_item" onClick={() => changeLanguage(true)}>
|
|
|
- <Text className="language_text">English</Text>
|
|
|
- {
|
|
|
- isEn && <Image className="check" src={require('@assets/index_time/check.png')} />
|
|
|
- }
|
|
|
-
|
|
|
+ <View className="language_item" onClick={() => changeLanguage(isEn ? true : false)}>
|
|
|
+ <Text className="language_text">{isEn ? 'English' : '中文'}</Text>
|
|
|
+ <Image className="check" src={require('@assets/index_time/check.png')} />
|
|
|
</View>
|
|
|
<View className="line" />
|
|
|
- <View className="language_item" onClick={() => changeLanguage(false)}>
|
|
|
- <Text className="language_text">中文</Text>
|
|
|
- {
|
|
|
- !isEn && <Image className="check" src={require('@assets/index_time/check.png')} />
|
|
|
- }
|
|
|
+ <View className="language_item" onClick={() => changeLanguage(isEn ? false : true)}>
|
|
|
+ <Text className="language_text">{!isEn ? 'English' : '中文'}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
@@ -375,72 +388,77 @@ export default function IndexTimePage() {
|
|
|
</View>
|
|
|
}
|
|
|
|
|
|
- return <View className="page_container">
|
|
|
- <View style={{ position: 'relative' }}>
|
|
|
- {
|
|
|
- ring()
|
|
|
- }
|
|
|
- <View className="ring_center">
|
|
|
- <Image className="sun" src={isNight() ? require('@assets/index_time/moon.png') : require('@assets/index_time/sun.png')} />
|
|
|
- <Text className="time">{formatTime('HH:mm:ss')}</Text>
|
|
|
- <Text className="date">{global.language == 'en' ? formatTime('dddd, MMM DD') : formatTime('MMMD dddd')}</Text>
|
|
|
+ function detail() {
|
|
|
+ return <View className="page_container">
|
|
|
+ <View style={{ position: 'relative' }}>
|
|
|
+ {
|
|
|
+ ring()
|
|
|
+ }
|
|
|
+ <View className="ring_center">
|
|
|
+ <Image className="sun" src={isNight() ? require('@assets/index_time/moon.png') : require('@assets/index_time/sun.png')} />
|
|
|
+ <Text className="time">{formatTime('HH:mm:ss')}</Text>
|
|
|
+ <Text className="date">{global.language == 'en' ? formatTime('dddd, MMM D') : formatTime('MMMD日 dddd')}</Text>
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- </View>
|
|
|
|
|
|
- <View className="location">
|
|
|
- <Image className="location_icon" src={require('@assets/index_time/pin.png')} />
|
|
|
- <Text className="location_text">{current ? getLocation() : t('time_of_day.index.unknown')}</Text>
|
|
|
- </View>
|
|
|
+ <View className="location">
|
|
|
+ <Image className="location_icon" src={require('@assets/index_time/pin.png')} />
|
|
|
+ <Text className="location_text">{current ? getLocation() : t('time_of_day.index.unknown')}</Text>
|
|
|
+ </View>
|
|
|
|
|
|
- <View style={{ flexDirection: 'row', marginTop: 10, alignItems: 'center' }} onClick={() => {
|
|
|
- if (current && current.time && current.time.timezone.use_dst) {
|
|
|
- setShowDst(true)
|
|
|
- }
|
|
|
- }}>
|
|
|
- <Text className="timezone">{current ? getTimezone1() : getTimezone()}</Text>
|
|
|
- {
|
|
|
- current && current.time && current.time.timezone.use_dst && <Image className="location_icon" src={require('@assets/index_time/arrow_right.png')} />
|
|
|
- }
|
|
|
+ <View style={{ flexDirection: 'row', marginTop: 10, alignItems: 'center' }} onClick={() => {
|
|
|
+ if (current && current.time && current.time.timezone.use_dst) {
|
|
|
+ setShowDst(true)
|
|
|
+ }
|
|
|
+ }}>
|
|
|
+ <Text className="timezone">{current ? getTimezone1() : getTimezone()}</Text>
|
|
|
+ {
|
|
|
+ current && current.time && current.time.timezone.use_dst && <Image className="location_icon" src={require('@assets/index_time/arrow_right.png')} />
|
|
|
+ }
|
|
|
|
|
|
- </View>
|
|
|
+ </View>
|
|
|
|
|
|
|
|
|
- <View className="btn_bg" onClick={goMap} onLongClick={goRecords}>
|
|
|
- <Text className="btn_text">{t('time_of_day.index.pick_location')}</Text>
|
|
|
+ <View className="btn_bg" onClick={goMap} onLongClick={goRecords} onLongPress={goRecords} onLongTap={goRecords}>
|
|
|
+ <Text className="btn_text">{!current ? t('time_of_day.index.pick_location') : t('time_of_day.index.change_location')}</Text>
|
|
|
+ {
|
|
|
+ current && <Image className="more" onClick={goRecords} src={require('@assets/index_time/more.png')} />
|
|
|
+ }
|
|
|
+
|
|
|
+ </View>
|
|
|
+ <View className="footer" onClick={() => setShowLanguage(true)}>
|
|
|
+ <Text className="footer_text">{isEn ? 'English' : '中文'}</Text>
|
|
|
+ <Image className="footer_icon" src={require('@assets/index_time/arrow.png')} />
|
|
|
+ </View>
|
|
|
{
|
|
|
- current && <Image className="more" onClick={goRecords} src={require('@assets/index_time/more.png')} />
|
|
|
+ showLanguage && <Modal
|
|
|
+ testInfo={null}
|
|
|
+ themeIsWhite={true}
|
|
|
+ dismiss={() => {
|
|
|
+ setShowLanguage(false)
|
|
|
+ }}
|
|
|
+ confirm={() => { }}>
|
|
|
+ {
|
|
|
+ languageModalContent()
|
|
|
+ }
|
|
|
+ </Modal>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ showDst && <Modal
|
|
|
+ testInfo={null}
|
|
|
+ themeIsWhite={true}
|
|
|
+ dismiss={() => {
|
|
|
+ setShowDst(false)
|
|
|
+ }}
|
|
|
+ confirm={() => { }}>
|
|
|
+ {
|
|
|
+ dstModalContent()
|
|
|
+ }
|
|
|
+ </Modal>
|
|
|
}
|
|
|
-
|
|
|
- </View>
|
|
|
- <View className="footer" onClick={() => setShowLanguage(true)}>
|
|
|
- <Text className="footer_text">{isEn ? 'English' : '中文'}</Text>
|
|
|
- <Image className="footer_icon" src={require('@assets/index_time/arrow.png')} />
|
|
|
</View>
|
|
|
- {
|
|
|
- showLanguage && <Modal
|
|
|
- testInfo={null}
|
|
|
- themeIsWhite={true}
|
|
|
- dismiss={() => {
|
|
|
- setShowLanguage(false)
|
|
|
- }}
|
|
|
- confirm={() => { }}>
|
|
|
- {
|
|
|
- languageModalContent()
|
|
|
- }
|
|
|
- </Modal>
|
|
|
- }
|
|
|
- {
|
|
|
- showDst && <Modal
|
|
|
- testInfo={null}
|
|
|
- themeIsWhite={true}
|
|
|
- dismiss={() => {
|
|
|
- setShowDst(false)
|
|
|
- }}
|
|
|
- confirm={() => { }}>
|
|
|
- {
|
|
|
- dstModalContent()
|
|
|
- }
|
|
|
- </Modal>
|
|
|
- }
|
|
|
- </View>
|
|
|
+ }
|
|
|
+
|
|
|
+ return detail()
|
|
|
+
|
|
|
}
|