|
|
@@ -10,7 +10,10 @@ const Component = forwardRef((props: {
|
|
|
limit: number, onChange: Function, onCancel: Function,
|
|
|
isRealTime?: boolean, limitDay?: number, time?: number, themeColor?: string, title?: string,
|
|
|
showEndTime?: boolean,
|
|
|
- duration?: number
|
|
|
+ duration?: number,
|
|
|
+ isFast?: boolean,
|
|
|
+ isEnd?: boolean,
|
|
|
+ endTimestamp?: number
|
|
|
}, ref) => {
|
|
|
|
|
|
const days: string[] = [];
|
|
|
@@ -45,14 +48,14 @@ const Component = forwardRef((props: {
|
|
|
date = new Date(global.set_time);
|
|
|
}
|
|
|
|
|
|
- date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
|
|
|
+ date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
|
|
|
date.setHours(values[1])
|
|
|
date.setMinutes(values[2])
|
|
|
global.picker_time = date.getTime()
|
|
|
}, [values])
|
|
|
|
|
|
|
|
|
- for (let i = props.limitDay ? props.limitDay - 1 : 6; i >= 0; i--) {
|
|
|
+ for (let i = props.limitDay ? props.limitDay - 1 : 5; i >= 0; i--) {
|
|
|
const date = new Date();
|
|
|
date.setDate(today.getDate() - i);
|
|
|
|
|
|
@@ -126,7 +129,7 @@ const Component = forwardRef((props: {
|
|
|
}
|
|
|
|
|
|
var date = new Date();
|
|
|
- date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
|
|
|
+ date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
|
|
|
const year = date.getFullYear();
|
|
|
const month = date.getMonth() + 1;
|
|
|
const day = date.getDate();
|
|
|
@@ -145,7 +148,7 @@ const Component = forwardRef((props: {
|
|
|
|
|
|
if (!props.isRealTime) {
|
|
|
date = new Date(global.set_time);
|
|
|
- date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
|
|
|
+ date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
|
|
|
}
|
|
|
|
|
|
//
|
|
|
@@ -161,7 +164,7 @@ const Component = forwardRef((props: {
|
|
|
}
|
|
|
|
|
|
|
|
|
- date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
|
|
|
+ date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
|
|
|
date.setHours(values[1])
|
|
|
date.setMinutes(values[2])
|
|
|
return date.getTime()
|
|
|
@@ -175,16 +178,39 @@ const Component = forwardRef((props: {
|
|
|
return num < 10 ? `0${num}` : `${num}`;
|
|
|
}
|
|
|
|
|
|
- function getEndTime(){
|
|
|
+ function getEndTime() {
|
|
|
var date = new Date(global.set_time);
|
|
|
- date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 6) - values[0]));
|
|
|
+ date.setDate(today.getDate() - ((props.limitDay ? props.limitDay - 1 : 5) - values[0]));
|
|
|
date.setHours(values[1])
|
|
|
date.setMinutes(values[2])
|
|
|
- var newDate = new Date(date.getTime()+props.duration!).getTime()
|
|
|
+ var newDate = new Date(date.getTime() + props.duration!).getTime()
|
|
|
if (global.language == 'en') {
|
|
|
return TimeFormatter.dateDescription(newDate, true) + ' ' + TimeFormatter.timeDescription(newDate)
|
|
|
- }
|
|
|
- return TimeFormatter.dateDescription(newDate, true) + '' + TimeFormatter.timeDescription(newDate)
|
|
|
+ }
|
|
|
+ return TimeFormatter.dateDescription(newDate, true) + '' + TimeFormatter.timeDescription(newDate)
|
|
|
+ }
|
|
|
+
|
|
|
+ function getEndTimestamp(timestamp) {
|
|
|
+ if (global.language == 'en') {
|
|
|
+ return TimeFormatter.dateDescription(timestamp, true) + ' ' + TimeFormatter.timeDescription(timestamp)
|
|
|
+ }
|
|
|
+ return TimeFormatter.dateDescription(timestamp, true) + '' + TimeFormatter.timeDescription(timestamp)
|
|
|
+ }
|
|
|
+
|
|
|
+ function pickerTimeText() {
|
|
|
+ if (props.isFast) {
|
|
|
+ if (props.isEnd) {
|
|
|
+ return `原定于${getEndTimestamp(props.endTimestamp!)}结束`
|
|
|
+ }
|
|
|
+ return `预计${getEndTime()}结束`
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (props.isEnd) {
|
|
|
+ return `原定于${getEndTimestamp(props.endTimestamp!)}起床`
|
|
|
+ }
|
|
|
+ return `预计${getEndTime()}起床`
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function pickerDetail() {
|
|
|
@@ -229,7 +255,7 @@ const Component = forwardRef((props: {
|
|
|
</View> */}
|
|
|
</View>
|
|
|
{
|
|
|
- props.showEndTime && <Text className="pickerEndTime">预计{getEndTime()}结束</Text>
|
|
|
+ props.showEndTime && <Text className="pickerEndTime">{pickerTimeText()}</Text>
|
|
|
}
|
|
|
<View className='modal_operate'>
|
|
|
<View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={cancel}>
|