Skip to content

Commit 57e2caf

Browse files
committed
issue 132: fixed duration of a week having 8 days
1 parent 6b3fb85 commit 57e2caf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/components/DateRangePicker/helpers.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,40 @@ const staticRangeHandler = {
5050
* @return {object[]} list of defined ranges
5151
*/
5252
export function createStaticRanges() {
53-
const now = moment().utcOffset(0);
54-
const pastWeek = now.clone().subtract(1, "week");
55-
const pastMonth = now.clone().subtract(1, "month");
56-
const past6Months = now.clone().subtract(6, "month");
57-
const pastYear = now.clone().subtract(1, "year");
53+
const today = moment();
54+
const endOfToday = today.set({ hour: 23, minute: 59, second: 59, millisecond: 999 });
55+
const pastWeek = endOfToday.clone().subtract(1, "week");
56+
const pastMonth = endOfToday.clone().subtract(1, "month");
57+
const past6Months = endOfToday.clone().subtract(6, "month");
58+
const pastYear = endOfToday.clone().subtract(1, "year");
5859

5960
const ranges = [
6061
{
6162
label: "Past Week",
6263
range: () => ({
6364
startDate: pastWeek.startOf("day").toDate(),
64-
endDate: now.endOf("day").toDate(),
65+
endDate: endOfToday.toDate(),
6566
}),
6667
},
6768
{
6869
label: "Past Month",
6970
range: () => ({
7071
startDate: pastMonth.startOf("day").toDate(),
71-
endDate: now.endOf("day").toDate(),
72+
endDate: endOfToday.toDate(),
7273
}),
7374
},
7475
{
7576
label: "Past 6 Months",
7677
range: () => ({
7778
startDate: past6Months.startOf("day").toDate(),
78-
endDate: now.endOf("day").toDate(),
79+
endDate: endOfToday.toDate(),
7980
}),
8081
},
8182
{
8283
label: "Past Year",
8384
range: () => ({
8485
startDate: pastYear.startOf("day").toDate(),
85-
endDate: now.endOf("day").toDate(),
86+
endDate: endOfToday.toDate(),
8687
}),
8788
},
8889
];

0 commit comments

Comments
 (0)