Skip to content

Commit cfb064a

Browse files
Ivan KitanovIvan Kitanov
authored andcommitted
Applying sugested changes
1 parent b00e42a commit cfb064a

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/components/date-range-picker/date-range-picker.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
convertToDate,
1515
convertToDateRange,
1616
} from '../calendar/helpers.js';
17-
import { toCalendarDay } from '../calendar/model.js';
17+
import { CalendarDay, toCalendarDay } from '../calendar/model.js';
1818
import {
1919
type DateRangeDescriptor,
2020
DateRangeType,
@@ -237,8 +237,8 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
237237
{
238238
label: IgcDateRangePickerResourceStringsEN.last7Days,
239239
dateRange: {
240-
start: this.createDate(-7),
241-
end: new Date(),
240+
start: CalendarDay.from(this.today).add('day', -7).native,
241+
end: CalendarDay.from(this.today).native,
242242
},
243243
},
244244
{
@@ -251,12 +251,8 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
251251
{
252252
label: IgcDateRangePickerResourceStringsEN.last30Days,
253253
dateRange: {
254-
start: this.createDate(-29),
255-
end: new Date(
256-
this.today.getFullYear(),
257-
this.today.getMonth(),
258-
this.today.getDate()
259-
),
254+
start: CalendarDay.from(this.today).add('day', -29).native,
255+
end: CalendarDay.from(this.today).native,
260256
},
261257
},
262258
{
@@ -914,12 +910,6 @@ export default class IgcDateRangePickerComponent extends FormAssociatedRequiredM
914910
}
915911
}
916912

917-
private createDate(daysOffset: number): Date {
918-
const date = new Date();
919-
date.setDate(date.getDate() + daysOffset);
920-
return date;
921-
}
922-
923913
private renderClearIcon(picker: 'start' | 'end' = 'start') {
924914
const clearIcon = !this.useTwoInputs
925915
? 'clear-icon'

0 commit comments

Comments
 (0)