Skip to content

Commit 55c8a6f

Browse files
committed
fix "Last X unit" minDate cutoff
1 parent 89d3cd4 commit 55c8a6f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/lib/date.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ export function parseDateValue(value: string) {
122122
if (!match) return null;
123123

124124
const { num, unit } = match.groups;
125+
const formattedNum = +num > 0 ? +num - 1 : +num;
125126

126-
return { num: +num, unit };
127+
return { num: formattedNum, unit };
127128
}
128129

129130
export function parseDateRange(value: string, locale = 'en-US'): DateRange {
@@ -157,12 +158,7 @@ export function parseDateRange(value: string, locale = 'en-US'): DateRange {
157158

158159
const now = new Date();
159160
const dateLocale = getDateLocale(locale);
160-
const { unit } = parseDateValue(value);
161-
let { num = 1 } = parseDateValue(value);
162-
163-
if (value === '7day') {
164-
num--;
165-
}
161+
const { num = 1, unit } = parseDateValue(value);
166162

167163
switch (unit) {
168164
case 'hour':

0 commit comments

Comments
 (0)