|
|
@@ -60,7 +60,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
const [sunriseDate, setSunriseDate] = useState<any>(sunriseA)
|
|
|
const [sunriseTmrDate, setSunriseTmrDate] = useState<any>(new Date(sunriseB.getTime() + 24 * 3600 * 1000))
|
|
|
const [sunsetDate, setSunsetDate] = useState<any>(sunsetA)
|
|
|
- const [status,setStatus] = useState('')
|
|
|
+ const [status, setStatus] = useState('')
|
|
|
|
|
|
|
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
@@ -254,7 +254,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
setSunriseTmrTime(data.daylights[1].sunrise)
|
|
|
setSunsetDate(yesterdayDate)
|
|
|
setSunriseTmrDate(todaySunriseDate)
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
@@ -277,14 +277,14 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
setSunriseTmrTime(data.daylights[2].sunrise)
|
|
|
setSunsetDate(todaySunsetDate)
|
|
|
setSunriseTmrDate(tomorrowSunriseDate)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
setSunriseTime(data.daylights[1].sunrise)
|
|
|
setSunsetTime(data.daylights[1].sunset)
|
|
|
setSunsetDate(todaySunsetDate)
|
|
|
setSunriseDate(todaySunriseDate)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
updateNightStore(today, data.daylights[2].sunrise, data.daylights[1].sunset)
|
|
|
updateDayStore(today, data.daylights[1].sunrise, data.daylights[1].sunset)
|
|
|
@@ -298,14 +298,14 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
setSunriseTmrTime(data.daylights[2].sunrise)
|
|
|
setSunsetDate(todaySunsetDate)
|
|
|
setSunriseTmrDate(tomorrowSunriseDate)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
setSunriseTime(data.daylights[2].sunrise)
|
|
|
setSunsetTime(data.daylights[2].sunset)
|
|
|
setSunriseDate(tomorrowSunriseDate)
|
|
|
setSunsetDate(tomorrowSunsetDate)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
updateNightStore(todaySunsetDate, data.daylights[2].sunrise, data.daylights[1].sunset)
|
|
|
updateDayStore(tomorrowSunriseDate, data.daylights[2].sunrise, data.daylights[2].sunset)
|
|
|
@@ -398,8 +398,8 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
|
|
|
var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`
|
|
|
// systemLocation({
|
|
|
- // lat: 77,
|
|
|
- // lng: 20,
|
|
|
+ // lat: 25.55,
|
|
|
+ // lng: -49.888,
|
|
|
// date_start: strYesterday,
|
|
|
// date_end: strTomorrow,
|
|
|
// coordinate_system_standard: 'GCJ-02'
|
|
|
@@ -956,12 +956,17 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
durationArc: 2
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (authInfo && authInfo.night_completed && new Date().getTime() > authInfo.night_completed.sunrise_ts) {
|
|
|
+ var now1 = new Date().getTime()
|
|
|
+ if (authInfo && authInfo.timezone) {
|
|
|
+ now1 = TimeFormatter.transferTimestamp(now1, authInfo.timezone)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (authInfo && authInfo.night_completed && now1 > authInfo.night_completed.sunrise_ts) {
|
|
|
realRingBig.color = ColorType.night
|
|
|
var duration = (authInfo.night_completed.sunrise_ts - authInfo.night_completed.sunset_ts) / 1000
|
|
|
// var start = new Date(authInfo.night_completed.sunset_ts)
|
|
|
- var newT = TimeFormatter.transferTimestamp(authInfo.night_completed.sunset_ts,authInfo.timezone)
|
|
|
+ var newT = TimeFormatter.transferTimestamp(authInfo.night_completed.sunset_ts, authInfo.timezone)
|
|
|
var start = new Date(newT)
|
|
|
realRingBig.startArc = (start.getHours() * 3600 + start.getMinutes() * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
realRingBig.durationArc = (duration) / (24 * 3600) * 2 * Math.PI;
|
|
|
@@ -986,8 +991,11 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
|
|
|
var currentDot = getDot(null, false)
|
|
|
currentDot.color = ColorType.night
|
|
|
+ currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0
|
|
|
|
|
|
var now = new Date()
|
|
|
+ now = localNow(now)
|
|
|
+
|
|
|
var t = now.getHours() * 60 + now.getMinutes()
|
|
|
var duration2 = t - sunSet
|
|
|
if (duration2 < 0) {
|
|
|
@@ -1001,7 +1009,6 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
|
|
|
if (nightStore.nightRingDate) {
|
|
|
if (new Date(nightStore.nightRingDate).getDate() == new Date().getDate() && new Date().getHours() < 12) {
|
|
|
-
|
|
|
realRing = null;
|
|
|
}
|
|
|
}
|
|
|
@@ -1016,6 +1023,13 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function localNow(now: Date) {
|
|
|
+ if (authInfo && authInfo.timezone) {
|
|
|
+ return new Date(TimeFormatter.transferTimestamp(now.getTime(), authInfo.timezone))
|
|
|
+ }
|
|
|
+ return now
|
|
|
+ }
|
|
|
+
|
|
|
function dayRing() {
|
|
|
var common = getCommon(null, true)
|
|
|
common.radius = bigRingRadius;
|
|
|
@@ -1028,12 +1042,17 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
durationArc: 2
|
|
|
}
|
|
|
|
|
|
- if (authInfo && authInfo.day_completed && new Date().getTime() > authInfo.day_completed.sunset_ts) {
|
|
|
+ var now1 = new Date().getTime()
|
|
|
+ if (authInfo && authInfo.timezone) {
|
|
|
+ now1 = TimeFormatter.transferTimestamp(now1, authInfo.timezone)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (authInfo && authInfo.day_completed && now1 > authInfo.day_completed.sunset_ts) {
|
|
|
realRingBig.color = ColorType.day
|
|
|
var duration = (authInfo.day_completed.sunset_ts - authInfo.day_completed.sunrise_ts) / 1000
|
|
|
// var start = new Date(authInfo.day_completed.sunrise_ts)
|
|
|
// var start = new Date(authInfo.night_completed.sunset_ts)
|
|
|
- var newT = TimeFormatter.transferTimestamp(authInfo.day_completed.sunrise_ts,authInfo.timezone)
|
|
|
+ var newT = TimeFormatter.transferTimestamp(authInfo.day_completed.sunrise_ts, authInfo.timezone)
|
|
|
var start = new Date(newT)
|
|
|
realRingBig.startArc = (start.getHours() * 3600 + start.getMinutes() * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0;
|
|
|
realRingBig.durationArc = (duration) / (24 * 3600) * 2 * Math.PI;
|
|
|
@@ -1057,6 +1076,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
realRingBig.durationArc = (duration * 60) / (24 * 3600) * 2 * Math.PI;
|
|
|
|
|
|
var currentDot = getDot(null, false)
|
|
|
+ currentDot.offset = (authInfo && authInfo.timezone) ? TimeFormatter.timeZoneOffset(authInfo.timezone) : 0
|
|
|
var date = new Date()
|
|
|
var minutes = date.getHours() * 60 + date.getMinutes()
|
|
|
if (minutes < sunRise) {
|
|
|
@@ -1099,10 +1119,11 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
|
|
|
var now = new Date()
|
|
|
+ now = localNow(now)
|
|
|
if (props.isNight && sunsetDate) {
|
|
|
if (now.getTime() > sunsetDate.getTime()) {
|
|
|
- global.sunsetDuration = TimeFormatter.countdown(sunsetDate.getTime())
|
|
|
- return TimeFormatter.countdown(sunsetDate.getTime())
|
|
|
+ global.sunsetDuration = TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
|
+ return TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
|
}
|
|
|
// return TimeFormatter.countdown(sunsetDate.getTime())
|
|
|
}
|
|
|
@@ -1195,29 +1216,36 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- function currentStatus(){
|
|
|
- if (showArrow()){
|
|
|
- return '过去'
|
|
|
+ function currentStatus() {
|
|
|
+ if (showArrow()) {
|
|
|
+ if (props.isNight) {
|
|
|
+ if (authInfo.day_completed && new Date().getTime() > authInfo.day_completed.sunset_ts) {
|
|
|
+ return '更新暂停'
|
|
|
+ }
|
|
|
+ return '已结束'
|
|
|
+ }
|
|
|
+ return '更新暂停'
|
|
|
}
|
|
|
- var strTime = props.isNight?getSunsetDuration():getSunriseDuration()
|
|
|
- return (strTime.indexOf('小时')!=-1||strTime.indexOf('分钟')!=-1)?'即将到来':'当前'
|
|
|
+ var strTime = props.isNight ? getSunsetDuration() : getSunriseDuration()
|
|
|
+ return (strTime.indexOf('小时') != -1 || strTime.indexOf('分钟') != -1) ? '即将到来' : '正在进行'
|
|
|
}
|
|
|
|
|
|
function footerDesc() {
|
|
|
var now = new Date()
|
|
|
+ now = localNow(now)
|
|
|
if (props.isNight) {
|
|
|
if (now.getTime() < sunsetDate.getTime()) {
|
|
|
- return '距日落' + TimeFormatter.countdown(sunsetDate.getTime())
|
|
|
+ return '距日落' + TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
|
|
|
|
}
|
|
|
- return '距日出' + TimeFormatter.countdown(sunriseTmrDate.getTime())
|
|
|
+ return '距日出' + TimeFormatter.countdown(sunriseTmrDate.getTime(), now.getTime())
|
|
|
}
|
|
|
|
|
|
if (now.getTime() > sunriseDate.getTime() && now.getTime() < sunsetDate.getTime()) {
|
|
|
|
|
|
- return '距日落' + TimeFormatter.countdown(sunsetDate.getTime())
|
|
|
+ return '距日落' + TimeFormatter.countdown(sunsetDate.getTime(), now.getTime())
|
|
|
}
|
|
|
- return '距日出' + TimeFormatter.countdown(sunriseDate.getTime())
|
|
|
+ return '距日出' + TimeFormatter.countdown(sunriseDate.getTime(), now.getTime())
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1280,7 +1308,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
</View> */}
|
|
|
<View className='day_card_header'>
|
|
|
- <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{currentStatus()}</View>
|
|
|
+ <View className='free' style={{ backgroundColor: props.isNight ? ColorType.night : ColorType.day, color: props.isNight ? '#fff' : '#1C1C1C' }}>{currentStatus()}</View>
|
|
|
</View>
|
|
|
<View className='day_card_footer'>
|
|
|
<Text className='day_card_footer_date'>
|
|
|
@@ -1296,7 +1324,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
|
|
|
}
|
|
|
|
|
|
{
|
|
|
- !showArrow() && <Text className='footer_desc_text' style={{ color: props.isNight?ColorType.night:ColorType.day,opacity:0.4 }}>{footerDesc()}</Text>
|
|
|
+ !showArrow() && <Text className='footer_desc_text' style={{ color: props.isNight ? ColorType.night : ColorType.day, opacity: 0.4 }}>{footerDesc()}</Text>
|
|
|
}
|
|
|
</View>
|
|
|
</View>
|