Skip to content

Commit

Permalink
Do not create new Date instances for DATERANGE update tags
Browse files Browse the repository at this point in the history
(Do not parse start and end date attributes already parsed in another DateRange tag with the same ID)
  • Loading branch information
robwalch committed Jun 5, 2024
1 parent 44e8d31 commit 341b680
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/loader/date-range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ export class DateRange {
);
}
this.attr = dateRangeAttr;
this._startDate = new Date(dateRangeAttr[DateRangeAttribute.START_DATE]);
this._startDate = dateRangeWithSameId
? dateRangeWithSameId.startDate
: new Date(dateRangeAttr[DateRangeAttribute.START_DATE]);
if (DateRangeAttribute.END_DATE in this.attr) {
const endDate = new Date(this.attr[DateRangeAttribute.END_DATE]);
const endDate =
dateRangeWithSameId?.endDate ||
new Date(this.attr[DateRangeAttribute.END_DATE]);
if (Number.isFinite(endDate.getTime())) {
this._endDate = endDate;
}
Expand Down

0 comments on commit 341b680

Please sign in to comment.