|
|
@@ -46,9 +46,6 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
|
|
|
useEffect(() => {
|
|
|
setInterval(() => {
|
|
|
- if (!expand) {
|
|
|
- return
|
|
|
- }
|
|
|
setCount((prevCounter) => prevCounter + 1)
|
|
|
}, 1000)
|
|
|
}, [])
|
|
|
@@ -199,6 +196,20 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
now.setHours(hour)
|
|
|
now.setMinutes(min)
|
|
|
now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunriseDate = new Date()
|
|
|
+ var list2 = sunriseTmrTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunriseDate.setHours(hour2)
|
|
|
+ sunriseDate.setMinutes(min2)
|
|
|
+ sunriseDate.setSeconds(second2)
|
|
|
+
|
|
|
+ if (new Date().getTime()<sunriseDate.getTime()){
|
|
|
+ return TimeFormatter.countdown(now.getTime()-24*3600*1000)
|
|
|
+ }
|
|
|
+
|
|
|
return TimeFormatter.countdown(now.getTime())
|
|
|
} else {
|
|
|
var list = sunriseTime.split(':')
|
|
|
@@ -208,10 +219,119 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
now.setHours(hour)
|
|
|
now.setMinutes(min)
|
|
|
now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunsetDate = new Date()
|
|
|
+ var list2 = sunsetTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunsetDate.setHours(hour2)
|
|
|
+ sunsetDate.setMinutes(min2)
|
|
|
+ sunsetDate.setSeconds(second2)
|
|
|
+ if (new Date().getTime() < sunsetDate.getTime()) {
|
|
|
+ return TimeFormatter.countdown(now.getTime())
|
|
|
+ }
|
|
|
+
|
|
|
+ var sunriseTDate = new Date()
|
|
|
+ var list3 = sunriseTmrTime.split(':')
|
|
|
+ var hour3 = parseInt(list3[0])
|
|
|
+ var min3 = parseInt(list3[1])
|
|
|
+ var second3 = list3.length == 3 ? parseInt(list3[2]) : 0
|
|
|
+ sunriseTDate.setHours(hour3)
|
|
|
+ sunriseTDate.setMinutes(min3)
|
|
|
+ sunriseTDate.setSeconds(second3)
|
|
|
+ return TimeFormatter.countdown(sunriseTDate.getTime() + 24 * 3600 * 1000)
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function timeCount2() {
|
|
|
+ var now = new Date()
|
|
|
+ if (props.isNight) {
|
|
|
+ var list = sunriseTmrTime.split(':')
|
|
|
+ var hour = parseInt(list[0])
|
|
|
+ var min = parseInt(list[1])
|
|
|
+ var second = list.length == 3 ? parseInt(list[2]) : 0
|
|
|
+ now.setHours(hour)
|
|
|
+ now.setMinutes(min)
|
|
|
+ now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunsetDate = new Date()
|
|
|
+ var list2 = sunsetTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunsetDate.setHours(hour2)
|
|
|
+ sunsetDate.setMinutes(min2)
|
|
|
+ sunsetDate.setSeconds(second2)
|
|
|
+ if (new Date().getTime() < sunsetDate.getTime()) {
|
|
|
+ return TimeFormatter.countdown(now.getTime())
|
|
|
+ }
|
|
|
+
|
|
|
+ return TimeFormatter.countdown(now.getTime() + 24 * 3600 * 1000)
|
|
|
+ } else {
|
|
|
+ var list = sunsetTime.split(':')
|
|
|
+ var hour = parseInt(list[0])
|
|
|
+ var min = parseInt(list[1])
|
|
|
+ var second = list.length == 3 ? parseInt(list[2]) : 0
|
|
|
+ now.setHours(hour)
|
|
|
+ now.setMinutes(min)
|
|
|
+ now.setSeconds(second)
|
|
|
return TimeFormatter.countdown(now.getTime())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function showExtraData() {
|
|
|
+ var now = new Date()
|
|
|
+ if (props.isNight) {
|
|
|
+ var list = sunsetTime.split(':')
|
|
|
+ var hour = parseInt(list[0])
|
|
|
+ var min = parseInt(list[1])
|
|
|
+ var second = list.length == 3 ? parseInt(list[2]) : 0
|
|
|
+ now.setHours(hour)
|
|
|
+ now.setMinutes(min)
|
|
|
+ now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunriseDate = new Date()
|
|
|
+ var list2 = sunriseTmrTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunriseDate.setHours(hour2)
|
|
|
+ sunriseDate.setMinutes(min2)
|
|
|
+ sunriseDate.setSeconds(second2)
|
|
|
+ if (sunriseDate.getTime()>new Date().getTime()){
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ if (now.getTime() > new Date().getTime()) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ var list = sunriseTime.split(':')
|
|
|
+ var hour = parseInt(list[0])
|
|
|
+ var min = parseInt(list[1])
|
|
|
+ var second = list.length == 3 ? parseInt(list[2]) : 0
|
|
|
+ now.setHours(hour)
|
|
|
+ now.setMinutes(min)
|
|
|
+ now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunsetDate = new Date()
|
|
|
+ var list2 = sunsetTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunsetDate.setHours(hour2)
|
|
|
+ sunsetDate.setMinutes(min2)
|
|
|
+ sunsetDate.setSeconds(second2)
|
|
|
+
|
|
|
+ if (now.getTime() < new Date().getTime() && new Date().getTime() < sunsetDate.getTime()) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
function timeDesc() {
|
|
|
var now = new Date()
|
|
|
if (props.isNight) {
|
|
|
@@ -222,6 +342,19 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
now.setHours(hour)
|
|
|
now.setMinutes(min)
|
|
|
now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunriseDate = new Date()
|
|
|
+ var list2 = sunriseTmrTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunriseDate.setHours(hour2)
|
|
|
+ sunriseDate.setMinutes(min2)
|
|
|
+ sunriseDate.setSeconds(second2)
|
|
|
+ if (sunriseDate.getTime()>new Date().getTime()){
|
|
|
+ return 'Time past Sunset'
|
|
|
+ }
|
|
|
+
|
|
|
if (now.getTime() < new Date().getTime()) {
|
|
|
return 'Time past Sunset'
|
|
|
}
|
|
|
@@ -235,6 +368,19 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
now.setHours(hour)
|
|
|
now.setMinutes(min)
|
|
|
now.setSeconds(second)
|
|
|
+
|
|
|
+ var sunsetDate = new Date()
|
|
|
+ var list2 = sunsetTime.split(':')
|
|
|
+ var hour2 = parseInt(list2[0])
|
|
|
+ var min2 = parseInt(list2[1])
|
|
|
+ var second2 = list2.length == 3 ? parseInt(list2[2]) : 0
|
|
|
+ sunsetDate.setHours(hour2)
|
|
|
+ sunsetDate.setMinutes(min2)
|
|
|
+ sunsetDate.setSeconds(second2)
|
|
|
+
|
|
|
+ if (new Date().getTime() > sunsetDate.getTime()) {
|
|
|
+ return 'Time to Sunrise'
|
|
|
+ }
|
|
|
if (now.getTime() < new Date().getTime()) {
|
|
|
return 'Time past Sunrise'
|
|
|
}
|
|
|
@@ -242,6 +388,13 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function timeDesc2() {
|
|
|
+ if (props.isNight) {
|
|
|
+ return 'Time to Sunrise'
|
|
|
+ }
|
|
|
+ return 'Time to Sunset'
|
|
|
+ }
|
|
|
+
|
|
|
function clearData() {
|
|
|
Taro.showModal({
|
|
|
title: '提示',
|
|
|
@@ -352,6 +505,8 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
return <View style={{ color: '#fff' }}>
|
|
|
<Box onClick={tapCard}>
|
|
|
<View>
|
|
|
@@ -394,8 +549,19 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
|
|
|
<View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
<Text style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{props.isNight ? `Today ${sunsetTime} - Tomorrow ${sunriseTmrTime}` : `${sunriseTime} - ${sunsetTime}`}</Text>
|
|
|
<Text>{props.isNight ? 'Sunset to Sunrise' : 'Sunrise to Sunset'}</Text>
|
|
|
- <Text style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{timeCount()}</Text>
|
|
|
- <Text>{timeDesc()}</Text>
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(300) }}>
|
|
|
+ <Text style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{timeCount()}</Text>
|
|
|
+ <Text>{timeDesc()}</Text>
|
|
|
+ </View>
|
|
|
+ {
|
|
|
+ showExtraData() && <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(300) }}>
|
|
|
+ <Text style={{ color: props.isNight ? ColorType.night : ColorType.day }}>{timeCount2()}</Text>
|
|
|
+ <Text>{timeDesc2()}</Text>
|
|
|
+ </View>
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+
|
|
|
</View>
|
|
|
{
|
|
|
footer()
|