|
|
@@ -43,7 +43,7 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
}, [props.data])
|
|
|
|
|
|
|
|
|
- function formateTime(obj: any, isEnd: boolean) {
|
|
|
+ function formateTime(obj: any, isEnd: boolean, isFastMode?: boolean) {
|
|
|
if (isEnd) {
|
|
|
if (obj.real_end_time) {
|
|
|
var newTimestamp = TimeFormatter.transferTimestamp(obj.real_end_time, obj.real_end_time_zone)
|
|
|
@@ -51,33 +51,41 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
// return diffTimeZone ? TimeFormatter.timelineFullFormatTime(newTimestamp) : TimeFormatter.timelineFormatTime(obj.real_end_time)
|
|
|
}
|
|
|
else {
|
|
|
- return TimeFormatter.timelineFormatTime(obj.target_end_time)
|
|
|
+
|
|
|
+ var real_time_zone = props.data.last_time_zone
|
|
|
+
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.target_end_time, real_time_zone)
|
|
|
+ return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
// return diffTimeZone ? TimeFormatter.timelineFullFormatTime(obj.target_end_time) : TimeFormatter.timelineFormatTime(obj.target_end_time)
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+
|
|
|
if (obj.real_start_time) {
|
|
|
var newTimestamp = TimeFormatter.transferTimestamp(obj.real_start_time, obj.real_start_time_zone)
|
|
|
return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
// return diffTimeZone ? TimeFormatter.timelineFullFormatTime(newTimestamp) : TimeFormatter.timelineFormatTime(obj.real_start_time)
|
|
|
}
|
|
|
else {
|
|
|
- return TimeFormatter.timelineFormatTime(obj.target_start_time)
|
|
|
+ var real_time_zone = props.data.last_time_zone
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.target_start_time, real_time_zone)
|
|
|
+
|
|
|
+ return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
// return diffTimeZone ? TimeFormatter.timelineFullFormatTime(obj.target_start_time) : TimeFormatter.timelineFormatTime(obj.target_start_time)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- function formateDate(currentStatus:string,obj: any, isEnd: boolean, isFastMode?: boolean) {
|
|
|
+ function formateDate(currentStatus: string, obj: any, isEnd: boolean, isFastMode?: boolean) {
|
|
|
var now = new Date()
|
|
|
var seconds = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()
|
|
|
if (currentStatus == 'WAIT_FOR_START') {
|
|
|
- if (props.data.scenario == 'SLEEP'){
|
|
|
- if (isEnd){
|
|
|
+ if (props.data.scenario == 'SLEEP') {
|
|
|
+ if (isEnd) {
|
|
|
var count = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.start_time)
|
|
|
var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.end_time)
|
|
|
- if (count2<count){
|
|
|
+ if (count2 < count) {
|
|
|
return global.language == 'en' ? 'Tomorrow' : '明天'
|
|
|
}
|
|
|
return global.language == 'en' ? 'Today' : '今天'
|
|
|
@@ -85,25 +93,25 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
}
|
|
|
else {
|
|
|
var count = TimeFormatter.timestringToSeconds(scenario.schedule.fast.start_time)
|
|
|
- if (isFastMode){
|
|
|
- if (isEnd){
|
|
|
+ if (isFastMode) {
|
|
|
+ if (isEnd) {
|
|
|
var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.fast.end_time)
|
|
|
- if (count2<count){
|
|
|
+ if (count2 < count) {
|
|
|
return global.language == 'en' ? 'Tomorrow' : '明天'
|
|
|
}
|
|
|
}
|
|
|
return global.language == 'en' ? 'Today' : '今天'
|
|
|
}
|
|
|
else {
|
|
|
- if (isEnd){
|
|
|
+ if (isEnd) {
|
|
|
var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.end_time)
|
|
|
- if (count2<count){
|
|
|
+ if (count2 < count) {
|
|
|
return global.language == 'en' ? 'Tomorrow' : '明天'
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
var count2 = TimeFormatter.timestringToSeconds(scenario.schedule.sleep.start_time)
|
|
|
- if (count2<count){
|
|
|
+ if (count2 < count) {
|
|
|
return global.language == 'en' ? 'Tomorrow' : '明天'
|
|
|
}
|
|
|
}
|
|
|
@@ -114,18 +122,36 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
}
|
|
|
if (isEnd) {
|
|
|
if (obj.real_end_time) {
|
|
|
- return TimeFormatter.dateDescription(obj.real_end_time, true)
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.real_end_time, obj.real_end_time_zone)
|
|
|
+ if (diffTimeZone || multTimeZone){
|
|
|
+ return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp,true)+' '
|
|
|
+ }
|
|
|
+ return TimeFormatter.dateDescription(newTimestamp, true, diffTimeZone || multTimeZone)
|
|
|
}
|
|
|
else {
|
|
|
- return TimeFormatter.dateDescription(obj.target_end_time, true)
|
|
|
+ var real_time_zone = props.data.last_time_zone
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.target_end_time, real_time_zone)
|
|
|
+ if (diffTimeZone || multTimeZone){
|
|
|
+ return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp,true)+' '
|
|
|
+ }
|
|
|
+ return TimeFormatter.dateDescription(newTimestamp, true, diffTimeZone || multTimeZone)
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
if (obj.real_start_time) {
|
|
|
- return TimeFormatter.dateDescription(obj.real_start_time, true)
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.real_start_time, obj.real_start_time_zone)
|
|
|
+ if (diffTimeZone || multTimeZone){
|
|
|
+ return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp,true)+' '
|
|
|
+ }
|
|
|
+ return TimeFormatter.dateDescription(newTimestamp, true, diffTimeZone || multTimeZone)
|
|
|
}
|
|
|
else {
|
|
|
- return TimeFormatter.dateDescription(obj.target_start_time, true)
|
|
|
+ var real_time_zone = props.data.last_time_zone
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.target_start_time, real_time_zone)
|
|
|
+ if (diffTimeZone || multTimeZone){
|
|
|
+ return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp,true)+' '
|
|
|
+ }
|
|
|
+ return TimeFormatter.dateDescription(obj.target_start_time, true, diffTimeZone || multTimeZone)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -142,28 +168,40 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
if (props.data.fast.real_start_time_zone) {
|
|
|
timeZone = ' ' + props.data.fast.real_start_time_zone
|
|
|
}
|
|
|
+ var desc = props.data.status == 'WAIT_FOR_START' ? '' : multTimeZone ? timeZone : ''
|
|
|
+ if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED' && diffTimeZone) {
|
|
|
+ desc = timeZone
|
|
|
+ }
|
|
|
timelineItems.push(
|
|
|
{
|
|
|
status: getStatus(true, true, props.data),
|
|
|
title: getStatus(true, true, props.data) == 'padding' ?
|
|
|
t('feature.track_time_duration.common.start_fast') :
|
|
|
t('feature.track_time_duration.common.started_fasting'),
|
|
|
- content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status,props.data.fast, false, true) + scenario.schedule.fast.start_time : formateDate(props.data.status,props.data.fast, false) + formateTime(props.data.fast, false),
|
|
|
- date: props.data.status == 'WAIT_FOR_START' ? '' : multTimeZone ? timeZone : '',
|
|
|
+ content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status, props.data.fast, false, true) + scenario.schedule.fast.start_time : formateDate(props.data.status, props.data.fast, false, true) + formateTime(props.data.fast, false, true),
|
|
|
+ date: desc,
|
|
|
// (diffTimeZone ? timeZone : showDate(props.data.fast, false) ? formateDate(props.data.fast, false) : ''),
|
|
|
color: global.fastColor ? global.fastColor : ColorType.fast
|
|
|
}
|
|
|
)
|
|
|
}
|
|
|
if (props.data.sleep && props.data.scenario != 'FAST') {
|
|
|
+
|
|
|
+ var status = getStatus(false, true, props.data)
|
|
|
+ var strContent = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status, props.data.sleep, false, false) + scenario.schedule.sleep.start_time : formateDate(props.data.status, props.data.sleep, false, false) + formateTime(props.data.sleep, false, false)
|
|
|
+
|
|
|
+
|
|
|
var timeZone = ''
|
|
|
if (props.data.sleep.real_start_time_zone) {
|
|
|
timeZone = ' ' + props.data.sleep.real_start_time_zone
|
|
|
}
|
|
|
- var status = getStatus(false, true, props.data)
|
|
|
- var strContent = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status,props.data.sleep, false, false) + scenario.schedule.sleep.start_time : formateDate(props.data.status,props.data.sleep, false) + formateTime(props.data.sleep, false)
|
|
|
var strDate = multTimeZone ? timeZone : ''
|
|
|
- // (diffTimeZone ? timeZone : showDate(props.data.sleep, false) ? formateDate(props.data.sleep, false) : '')
|
|
|
+ if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED') {
|
|
|
+ if ((!timeZone || timeZone.length == 0) && (multTimeZone || diffTimeZone)) {
|
|
|
+ strDate = props.data.last_time_zone
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
timelineItems.push(
|
|
|
{
|
|
|
status: status,
|
|
|
@@ -182,8 +220,16 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
timeZone = ' ' + props.data.sleep.real_end_time_zone
|
|
|
}
|
|
|
var status = getStatus(false, false, props.data)
|
|
|
- var strContent: string = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status,props.data.sleep, true, false) + scenario.schedule.sleep.end_time : formateDate(props.data.status,props.data.sleep, true) + formateTime(props.data.sleep, true)
|
|
|
+ var strContent: string = props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status, props.data.sleep, true, false) + scenario.schedule.sleep.end_time : formateDate(props.data.status, props.data.sleep, true) + formateTime(props.data.sleep, true, false)
|
|
|
var strDate = multTimeZone ? timeZone : ''
|
|
|
+
|
|
|
+ if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED') {
|
|
|
+ if ((!timeZone || timeZone.length == 0) && (multTimeZone || diffTimeZone)) {
|
|
|
+ strDate = props.data.last_time_zone
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// (diffTimeZone ? timeZone : showDate(props.data.sleep, true) ? formateDate(props.data.sleep, true) : '')
|
|
|
timelineItems.push(
|
|
|
{
|
|
|
@@ -202,14 +248,27 @@ export default function TimelineFastSleep(props: { data: any, title?: string, fi
|
|
|
if (props.data.fast.real_end_time_zone) {
|
|
|
timeZone = ' ' + props.data.fast.real_end_time_zone
|
|
|
}
|
|
|
+
|
|
|
+ console.log(timeZone, multTimeZone, diffTimeZone, props.data.status)
|
|
|
+ if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED') {
|
|
|
+ if ((!timeZone || timeZone.length == 0) && (multTimeZone || diffTimeZone)) {
|
|
|
+ timeZone = props.data.last_time_zone
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((diffTimeZone && !multTimeZone) && props.data.status == 'COMPLETED') {
|
|
|
+ timeZone = ''
|
|
|
+ }
|
|
|
+
|
|
|
timelineItems.push(
|
|
|
{
|
|
|
status: getStatus(true, false, props.data),
|
|
|
title: getStatus(true, false, props.data) == 'padding' ?
|
|
|
t('feature.track_time_duration.common.end_fast') :
|
|
|
t('feature.track_time_duration.common.ended_fasting'),
|
|
|
- content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status,props.data.fast, true, true) + scenario.schedule.fast.end_time : formateDate(props.data.status,props.data.fast, true) + formateTime(props.data.fast, true),
|
|
|
- date: multTimeZone ? timeZone : '',
|
|
|
+ content: props.data.status == 'WAIT_FOR_START' ? formateDate(props.data.status, props.data.fast, true, true) + scenario.schedule.fast.end_time : formateDate(props.data.status, props.data.fast, true) + formateTime(props.data.fast, true, true),
|
|
|
+ // date: multTimeZone ? timeZone : '',
|
|
|
+ date: timeZone,
|
|
|
// (diffTimeZone ? timeZone : showDate(props.data.fast, true) ? formateDate(props.data.fast, true) : ''),
|
|
|
color: global.fastColor ? global.fastColor : ColorType.fast
|
|
|
}
|