date-picker: fix default-value DST (#14562)

pull/14795/head
Jiewei Qian 2019-03-21 20:18:27 +11:00 committed by iamkun
parent 3c4354e2fa
commit a149828889
1 changed files with 3 additions and 6 deletions

View File

@ -197,6 +197,7 @@
nextYear,
prevMonth,
nextMonth,
nextDate,
extractDateFormat,
extractTimeFormat
} from '../util';
@ -207,17 +208,13 @@
import ElInput from 'element-ui/packages/input';
import ElButton from 'element-ui/packages/button';
const advanceDate = (date, amount) => {
return new Date(new Date(date).getTime() + amount);
};
const calcDefaultValue = (defaultValue) => {
if (Array.isArray(defaultValue)) {
return [new Date(defaultValue[0]), new Date(defaultValue[1])];
} else if (defaultValue) {
return [new Date(defaultValue), advanceDate(defaultValue, 24 * 60 * 60 * 1000)];
return [new Date(defaultValue), nextDate(new Date(defaultValue), 1)];
} else {
return [new Date(), advanceDate(Date.now(), 24 * 60 * 60 * 1000)];
return [new Date(), nextDate(new Date(), 1)];
}
};