|
|
@@ -32,45 +32,17 @@ export default function TimelineFastSleep(props: {
|
|
|
const [multTimeZone] = useState(props.multiTimeZone)
|
|
|
const scenario = props.scenario ? props.scenario : useSelector((state: any) => state.scenario);
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- // var split = new Date().toString().split(' ');
|
|
|
- // var currentTZ = split[split.length - 2];
|
|
|
- // 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_end_time_zone && props.data.fast.real_end_time_zone != currentTZ) {
|
|
|
- // setDiffTimeZone(true)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // 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_end_time_zone && props.data.sleep.real_end_time_zone != currentTZ) {
|
|
|
- // setDiffTimeZone(true)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // }
|
|
|
- // setDiffTimeZone(false)
|
|
|
-
|
|
|
- }, [props.data])
|
|
|
-
|
|
|
|
|
|
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)
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.real_end_time, obj.real_end_timezone.gmt)
|
|
|
return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
// return diffTimeZone ? TimeFormatter.timelineFullFormatTime(newTimestamp) : TimeFormatter.timelineFormatTime(obj.real_end_time)
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
- var real_time_zone = props.data.last_time_zone
|
|
|
+ var real_time_zone = props.data.last_timezone.gmt
|
|
|
|
|
|
var newTimestamp = TimeFormatter.transferTimestamp(obj.target_end_time, real_time_zone)
|
|
|
return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
@@ -80,12 +52,12 @@ export default function TimelineFastSleep(props: {
|
|
|
else {
|
|
|
|
|
|
if (obj.real_start_time) {
|
|
|
- var newTimestamp = TimeFormatter.transferTimestamp(obj.real_start_time, obj.real_start_time_zone)
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.real_start_time, obj.real_start_timezone.gmt)
|
|
|
return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
// return diffTimeZone ? TimeFormatter.timelineFullFormatTime(newTimestamp) : TimeFormatter.timelineFormatTime(obj.real_start_time)
|
|
|
}
|
|
|
else {
|
|
|
- var real_time_zone = props.data.last_time_zone
|
|
|
+ var real_time_zone = props.data.last_timezone.gmt
|
|
|
var newTimestamp = TimeFormatter.transferTimestamp(obj.target_start_time, real_time_zone)
|
|
|
|
|
|
return TimeFormatter.timelineFormatTime(newTimestamp)
|
|
|
@@ -140,14 +112,14 @@ export default function TimelineFastSleep(props: {
|
|
|
}
|
|
|
if (isEnd) {
|
|
|
if (obj.real_end_time) {
|
|
|
- var newTimestamp = TimeFormatter.transferTimestamp(obj.real_end_time, obj.real_end_time_zone)
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.real_end_time, obj.real_end_timezone.gmt)
|
|
|
if (diffTimeZone || multTimeZone) {
|
|
|
return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp, true) + ' '
|
|
|
}
|
|
|
return TimeFormatter.dateDescription(newTimestamp, true, diffTimeZone || multTimeZone)
|
|
|
}
|
|
|
else {
|
|
|
- var real_time_zone = props.data.last_time_zone
|
|
|
+ var real_time_zone = props.data.last_timezone.gmt
|
|
|
var newTimestamp = TimeFormatter.transferTimestamp(obj.target_end_time, real_time_zone)
|
|
|
if (diffTimeZone || multTimeZone) {
|
|
|
return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp, true) + ' '
|
|
|
@@ -157,14 +129,14 @@ export default function TimelineFastSleep(props: {
|
|
|
}
|
|
|
else {
|
|
|
if (obj.real_start_time) {
|
|
|
- var newTimestamp = TimeFormatter.transferTimestamp(obj.real_start_time, obj.real_start_time_zone)
|
|
|
+ var newTimestamp = TimeFormatter.transferTimestamp(obj.real_start_time, obj.real_start_timezone.gmt)
|
|
|
if (diffTimeZone || multTimeZone) {
|
|
|
return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp, true) + ' '
|
|
|
}
|
|
|
return TimeFormatter.dateDescription(newTimestamp, true, diffTimeZone || multTimeZone)
|
|
|
}
|
|
|
else {
|
|
|
- var real_time_zone = props.data.last_time_zone
|
|
|
+ var real_time_zone = props.data.last_timezone.gmt
|
|
|
var newTimestamp = TimeFormatter.transferTimestamp(obj.target_start_time, real_time_zone)
|
|
|
if (diffTimeZone || multTimeZone) {
|
|
|
return TimeFormatter.getMonthAndDayByTimestamp(newTimestamp, true) + ' '
|
|
|
@@ -183,8 +155,8 @@ export default function TimelineFastSleep(props: {
|
|
|
*/
|
|
|
if (props.data.fast && props.data.scenario != 'SLEEP') {
|
|
|
var timeZone = ''
|
|
|
- if (props.data.fast.real_start_time_zone) {
|
|
|
- timeZone = ' ' + props.data.fast.real_start_time_zone
|
|
|
+ if (props.data.fast.real_start_timezone.gmt) {
|
|
|
+ timeZone = ' ' + props.data.fast.real_start_timezone.gmt
|
|
|
}
|
|
|
var desc = props.data.status == 'WAIT_FOR_START' ? '' : multTimeZone ? timeZone : ''
|
|
|
if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED' && diffTimeZone) {
|
|
|
@@ -210,13 +182,13 @@ export default function TimelineFastSleep(props: {
|
|
|
|
|
|
|
|
|
var timeZone = ''
|
|
|
- if (props.data.sleep.real_start_time_zone) {
|
|
|
- timeZone = ' ' + props.data.sleep.real_start_time_zone
|
|
|
+ if (props.data.sleep.real_start_timezone.gmt) {
|
|
|
+ timeZone = ' ' + props.data.sleep.real_start_timezone.gmt
|
|
|
}
|
|
|
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
|
|
|
+ strDate = props.data.last_timezone.gmt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -236,8 +208,8 @@ export default function TimelineFastSleep(props: {
|
|
|
}
|
|
|
if (props.data.sleep && props.data.scenario != 'FAST') {
|
|
|
var timeZone = ''
|
|
|
- if (props.data.sleep.real_end_time_zone) {
|
|
|
- timeZone = ' ' + props.data.sleep.real_end_time_zone
|
|
|
+ if (props.data.sleep.real_end_timezone.gmt) {
|
|
|
+ timeZone = ' ' + props.data.sleep.real_end_timezone.gmt
|
|
|
}
|
|
|
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, false)
|
|
|
@@ -245,7 +217,7 @@ export default function TimelineFastSleep(props: {
|
|
|
|
|
|
if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED') {
|
|
|
if ((!timeZone || timeZone.length == 0) && (multTimeZone || diffTimeZone)) {
|
|
|
- strDate = props.data.last_time_zone
|
|
|
+ strDate = props.data.last_timezone.gmt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -265,12 +237,12 @@ export default function TimelineFastSleep(props: {
|
|
|
}
|
|
|
if (props.data.fast && props.data.scenario != 'SLEEP') {
|
|
|
var timeZone = ''
|
|
|
- if (props.data.fast.real_end_time_zone) {
|
|
|
- timeZone = ' ' + props.data.fast.real_end_time_zone
|
|
|
+ if (props.data.fast.real_end_timezone.gmt) {
|
|
|
+ timeZone = ' ' + props.data.fast.real_end_timezone.gmt
|
|
|
}
|
|
|
if (props.data.status != 'WAIT_FOR_START' && props.data.status != 'COMPLETED') {
|
|
|
if ((!timeZone || timeZone.length == 0) && (multTimeZone || diffTimeZone)) {
|
|
|
- timeZone = props.data.last_time_zone
|
|
|
+ timeZone = props.data.last_timezone.gmt
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -298,16 +270,16 @@ export default function TimelineFastSleep(props: {
|
|
|
|
|
|
function getTZLocation() {
|
|
|
if (props.data.fast) {
|
|
|
- var name = props.data.fast.real_start_time_zone
|
|
|
- if (props.data.fast.real_start_time_zone_name) {
|
|
|
- name = `${name} (${props.data.fast.real_start_time_zone_name})`
|
|
|
+ var name = props.data.fast.real_start_timezone.gmt
|
|
|
+ if (props.data.fast.real_start_timezone.name) {
|
|
|
+ name = `${name} (${props.data.fast.real_start_timezone.name})`
|
|
|
}
|
|
|
return name
|
|
|
}
|
|
|
else {
|
|
|
- var name = props.data.sleep.real_start_time_zone
|
|
|
- if (props.data.sleep.real_start_time_zone_name) {
|
|
|
- name = `${name} (${props.data.sleep.real_start_time_zone_name})`
|
|
|
+ var name = props.data.sleep.real_start_timezone.gmt
|
|
|
+ if (props.data.sleep.real_start_timezone.name) {
|
|
|
+ name = `${name} (${props.data.sleep.real_start_timezone.name})`
|
|
|
}
|
|
|
return name
|
|
|
}
|
|
|
@@ -324,21 +296,21 @@ export default function TimelineFastSleep(props: {
|
|
|
var current1 = dayjs()
|
|
|
var current
|
|
|
if (props.data.fast) {
|
|
|
- if (props.data.fast.real_start_time_zone_id) {
|
|
|
- current = dayjs().tz(props.data.fast.real_start_time_zone_id)
|
|
|
+ if (props.data.fast.real_start_timezone.id) {
|
|
|
+ current = dayjs().tz(props.data.fast.real_start_timezone.id)
|
|
|
offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
|
|
|
}
|
|
|
else {
|
|
|
- offset = TimeFormatter.timeZoneOffset(props.data.fast.real_start_time_zone)
|
|
|
+ offset = TimeFormatter.timeZoneOffset(props.data.fast.real_start_timezone.gmt)
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- if (props.data.sleep.real_start_time_zone_id) {
|
|
|
- current = dayjs().tz(props.data.sleep.real_start_time_zone_id)
|
|
|
+ if (props.data.sleep.real_start_timezone.id) {
|
|
|
+ current = dayjs().tz(props.data.sleep.real_start_timezone.id)
|
|
|
offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
|
|
|
}
|
|
|
else {
|
|
|
- offset = TimeFormatter.timeZoneOffset(props.data.sleep.real_start_time_zone)
|
|
|
+ offset = TimeFormatter.timeZoneOffset(props.data.sleep.real_start_timezone.gmt)
|
|
|
}
|
|
|
}
|
|
|
// offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
|