|
@@ -19,42 +19,74 @@ import { useTranslation } from "react-i18next";
|
|
|
import { ColorType } from "@/context/themes/color";
|
|
import { ColorType } from "@/context/themes/color";
|
|
|
import TimelineStage from "./TimelineStage";
|
|
import TimelineStage from "./TimelineStage";
|
|
|
import { jumpPage } from "../hooks/Common";
|
|
import { jumpPage } from "../hooks/Common";
|
|
|
|
|
+import { sqrt } from 'mathjs'
|
|
|
|
|
|
|
|
export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function }) {
|
|
export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function }) {
|
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
const [segmentIndex, setSegmentIndex] = useState(0)
|
|
const [segmentIndex, setSegmentIndex] = useState(0)
|
|
|
const [diffTimeZone, setDiffTimeZone] = useState(false)
|
|
const [diffTimeZone, setDiffTimeZone] = useState(false)
|
|
|
|
|
+ const [multiTimeZone, setMultiTimeZone] = useState(false)
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
const canvasId = props.data.id
|
|
const canvasId = props.data.id
|
|
|
const record = props.data;
|
|
const record = props.data;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
+ checkTimezone()
|
|
|
|
|
+ console.log(sqrt(-4).toString())
|
|
|
|
|
+ }, [props.data])
|
|
|
|
|
+
|
|
|
|
|
+ function checkTimezone() {
|
|
|
var split = new Date().toString().split(' ');
|
|
var split = new Date().toString().split(' ');
|
|
|
var currentTZ = split[split.length - 2];
|
|
var currentTZ = split[split.length - 2];
|
|
|
|
|
+ var isDiff = false;
|
|
|
|
|
+ var isMulti = false;
|
|
|
|
|
+ var tempTZ = '';
|
|
|
if (props.data.fast) {
|
|
if (props.data.fast) {
|
|
|
- if (props.data.fast.real_start_time_zone && props.data.fast.real_start_time_zone != currentTZ) {
|
|
|
|
|
- setDiffTimeZone(true)
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if (props.data.fast.real_start_time_zone) {
|
|
|
|
|
+ tempTZ = props.data.fast.real_start_time_zone
|
|
|
|
|
+ if (props.data.fast.real_start_time_zone != currentTZ) {
|
|
|
|
|
+ isDiff = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (props.data.fast.real_end_time_zone && props.data.fast.real_end_time_zone != currentTZ) {
|
|
|
|
|
- setDiffTimeZone(true)
|
|
|
|
|
- return
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (props.data.fast.real_end_time_zone) {
|
|
|
|
|
+ if (tempTZ != props.data.fast.real_end_time_zone) {
|
|
|
|
|
+ isMulti = true
|
|
|
|
|
+ }
|
|
|
|
|
+ if (props.data.fast.real_end_time_zone != currentTZ) {
|
|
|
|
|
+ isDiff = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (props.data.sleep) {
|
|
if (props.data.sleep) {
|
|
|
- if (props.data.sleep.real_start_time_zone && props.data.sleep.real_start_time_zone != currentTZ) {
|
|
|
|
|
- setDiffTimeZone(true)
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ if (props.data.sleep.real_start_time_zone){
|
|
|
|
|
+ if (tempTZ == '') {
|
|
|
|
|
+ tempTZ = props.data.sleep.real_start_time_zone
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (tempTZ != props.data.sleep.real_start_time_zone) {
|
|
|
|
|
+ isMulti = true
|
|
|
|
|
+ }
|
|
|
|
|
+ if (props.data.sleep.real_start_time_zone != currentTZ) {
|
|
|
|
|
+ isDiff = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (props.data.sleep.real_end_time_zone && props.data.sleep.real_end_time_zone != currentTZ) {
|
|
|
|
|
- setDiffTimeZone(true)
|
|
|
|
|
- return
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (props.data.sleep.real_end_time_zone){
|
|
|
|
|
+ if (tempTZ != props.data.sleep.real_end_time_zone) {
|
|
|
|
|
+ isMulti = true
|
|
|
|
|
+ }
|
|
|
|
|
+ if (props.data.sleep.real_end_time_zone != currentTZ) {
|
|
|
|
|
+ isDiff = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- setDiffTimeZone(false)
|
|
|
|
|
-
|
|
|
|
|
- }, [props.data])
|
|
|
|
|
|
|
+ setDiffTimeZone(isDiff)
|
|
|
|
|
+ setMultiTimeZone(isMulti)
|
|
|
|
|
+ }
|
|
|
function del() {
|
|
function del() {
|
|
|
var id = props.data.id
|
|
var id = props.data.id
|
|
|
delRecord(id
|
|
delRecord(id
|
|
@@ -68,37 +100,22 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function subTitle(timestamp) {
|
|
|
|
|
+ if (multiTimeZone) {
|
|
|
|
|
+ return 'Multiple time zones'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (diffTimeZone) {
|
|
|
|
|
+ return 'Different time zone'
|
|
|
|
|
+ }
|
|
|
|
|
+ return TimeFormatter.getDateAndWeek(timestamp)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function schedules() {
|
|
function schedules() {
|
|
|
var timestamp = props.data.first_real_check_time
|
|
var timestamp = props.data.first_real_check_time
|
|
|
|
|
|
|
|
- // var split = new Date().toString().split(' ');
|
|
|
|
|
- // var currentTZ = split[split.length - 2];
|
|
|
|
|
- // var diffTimeZone = false
|
|
|
|
|
- // if (props.data.fast) {
|
|
|
|
|
- // if (props.data.fast.real_start_time_zone && props.data.fast.real_start_time_zone != currentTZ) {
|
|
|
|
|
- // diffTimeZone = true
|
|
|
|
|
- // }
|
|
|
|
|
- // if (props.data.fast.real_end_time_zone && props.data.fast.real_end_time_zone != currentTZ) {
|
|
|
|
|
- // diffTimeZone = true
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // if (props.data.sleep) {
|
|
|
|
|
- // if (props.data.sleep.real_start_time_zone && props.data.sleep.real_start_time_zone != currentTZ) {
|
|
|
|
|
- // diffTimeZone = true
|
|
|
|
|
- // }
|
|
|
|
|
- // if (props.data.sleep.real_end_time_zone && props.data.sleep.real_end_time_zone != currentTZ) {
|
|
|
|
|
- // diffTimeZone = true
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // if (props.data.first_time_zone){
|
|
|
|
|
- // timestamp = TimeFormatter.transferTimestamp(timestamp,props.data.first_time_zone)
|
|
|
|
|
- // }
|
|
|
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
return <View style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
- <TimelineStage data={props.data} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
|
|
|
|
|
- subTitle={diffTimeZone?'Multiple time zones':TimeFormatter.getDateAndWeek(timestamp)} first_real_check_time={timestamp}/>
|
|
|
|
|
|
|
+ <TimelineStage data={props.data} title={t('feature.track_time_duration.record_fast_sleep.pop_title')}
|
|
|
|
|
+ subTitle={subTitle(timestamp)} first_real_check_time={timestamp} />
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -131,7 +148,7 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
if (!end) {
|
|
if (!end) {
|
|
|
end = (new Date()).getTime()
|
|
end = (new Date()).getTime()
|
|
|
}
|
|
}
|
|
|
- return TimeFormatter.durationFormate(start,end)
|
|
|
|
|
|
|
+ return TimeFormatter.durationFormate(start, end)
|
|
|
// return TimeFormatter.calculateTimeDifference(start, end)
|
|
// return TimeFormatter.calculateTimeDifference(start, end)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -223,14 +240,24 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
</View>
|
|
</View>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function recordTime(){
|
|
|
|
|
|
|
+ function recordTime() {
|
|
|
var timestamp = props.data.first_real_check_time
|
|
var timestamp = props.data.first_real_check_time
|
|
|
- if (props.data.first_time_zone){
|
|
|
|
|
- timestamp = TimeFormatter.transferTimestamp(timestamp,props.data.first_time_zone)
|
|
|
|
|
|
|
+ if (props.data.first_time_zone) {
|
|
|
|
|
+ timestamp = TimeFormatter.transferTimestamp(timestamp, props.data.first_time_zone)
|
|
|
}
|
|
}
|
|
|
return TimeFormatter.dateDescription(timestamp, true)
|
|
return TimeFormatter.dateDescription(timestamp, true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function getArrowText() {
|
|
|
|
|
+ if (multiTimeZone) {
|
|
|
|
|
+ return 'Multiple time zones'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (diffTimeZone) {
|
|
|
|
|
+ return 'Different time zone'
|
|
|
|
|
+ }
|
|
|
|
|
+ return recordTime()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function recordDetail() {
|
|
function recordDetail() {
|
|
|
var fastDuration = ''
|
|
var fastDuration = ''
|
|
|
var sleepDuration = ''
|
|
var sleepDuration = ''
|
|
@@ -280,8 +307,8 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
|
|
|
</View>
|
|
</View>
|
|
|
{/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
|
|
{/* <Image className="arrow1" src={require('@/assets/images/arrow.png')} /> */}
|
|
|
<View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
<View className="record_arrow_bg" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>
|
|
|
- <View style={{flex:1}}/>
|
|
|
|
|
- <Text className='recordTime'>{diffTimeZone?'Multiple time zones':recordTime()}</Text>
|
|
|
|
|
|
|
+ <View style={{ flex: 1 }} />
|
|
|
|
|
+ <Text className='recordTime'>{getArrowText()}</Text>
|
|
|
<Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
<Image className="arrow2" src={require('@/assets/images/arrow3.png')} />
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|