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

fix(ui5-daterange-picker): fixed getters for first and last date values #2277

Merged
merged 4 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions packages/main/src/DateRangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ class DateRangePicker extends DatePicker {
this._firstDateTimestamp = Date.UTC(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate(), firstDate.getHours()) / 1000;
this._lastDateTimestamp = Date.UTC(secondDate.getFullYear(), secondDate.getMonth(), secondDate.getDate(), secondDate.getHours()) / 1000;


if (this._firstDateTimestamp > this._lastDateTimestamp) {
const temp = this._firstDateTimestamp;
this._firstDateTimestamp = this._lastDateTimestamp;
Expand Down Expand Up @@ -257,7 +256,7 @@ class DateRangePicker extends DatePicker {
*/
get firstDateValue() {
const dateValue = new Date(this._firstDateTimestamp * 1000);
return new Date(Date.UTC(dateValue.getFullYear(), dateValue.getMonth(), dateValue.getDate()));
return new Date(dateValue.getUTCFullYear(), dateValue.getUTCMonth(), dateValue.getUTCDate(), dateValue.getUTCHours());
}

/**
Expand All @@ -269,7 +268,7 @@ class DateRangePicker extends DatePicker {
*/
get lastDateValue() {
const dateValue = new Date(this._lastDateTimestamp * 1000);
return new Date(Date.UTC(dateValue.getFullYear(), dateValue.getMonth(), dateValue.getDate()));
return new Date(dateValue.getUTCFullYear(), dateValue.getUTCMonth(), dateValue.getUTCDate(), dateValue.getUTCHours());
}

get _placeholder() {
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class DayPicker extends UI5Element {
lastWeekNumber = -1,
isDaySelected = false,
todayIndex = 0;

const _aVisibleDays = this._getVisibleDays(this._calendarDate);
this._weeks = [];
let week = [];
Expand Down
6 changes: 3 additions & 3 deletions packages/main/test/specs/DateRangePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("DateRangePicker general interaction", () => {

daterangepicker.click();
daterangepicker.keys("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
daterangepicker.keys("09/09/2019 - 10/10/2019");
daterangepicker.keys("27/09/2019 - 10/10/2019");
daterangepicker.keys("Enter");

const res = browser.execute(() => {
Expand All @@ -54,8 +54,8 @@ describe("DateRangePicker general interaction", () => {
return {firstDateValue, lastDateValue};
});

assert.strictEqual(res.firstDateValue, "2019-09-09T00:00:00.000Z", "The first date is in JS Date format");
assert.strictEqual(res.lastDateValue, "2019-10-10T00:00:00.000Z", "The last date is JS Date format");
assert.deepEqual(new Date(res.firstDateValue), new Date(2019, 8, 27), "The first date is in JS Date format");
assert.deepEqual(new Date(res.lastDateValue), new Date(2019, 9, 10), "The last date is JS Date format");
});

it("Initially setting the same date as first & last is possible", () => {
Expand Down