Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date-range: fix default-value daylight saving #14562

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/date-picker/src/panel/date-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
nextYear,
prevMonth,
nextMonth,
nextDate,
extractDateFormat,
extractTimeFormat
} from '../util';
Expand All @@ -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)];
}
};

Expand Down