Skip to content

Commit

Permalink
Fix content end date if already in new year
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Jan 2, 2025
1 parent aa43202 commit 59fc568
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/content/schedule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ describe('Content Schedule', () => {
expect(matchers.seasonalGear.end).to.eql(moment.utc(`2025-03-21T${String(switchoverTime).padStart(2, '0')}:00:00.000Z`).toDate());
});

it('sets the end date in new year for a winter gala', () => {
const date = new Date('2025-01-04');
const matchers = getAllScheduleMatchingGroups(date);
expect(matchers.seasonalGear.end).to.eql(moment.utc(`2025-03-21T${String(switchoverTime).padStart(2, '0')}:00:00.000Z`).toDate());
});

it('uses correct date for first hours of the month', () => {
// if the date is checked before CONTENT_SWITCHOVER_TIME_OFFSET,
// it should be considered the previous month
Expand Down
4 changes: 3 additions & 1 deletion website/common/script/content/constants/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,9 @@ function makeEndDate (checkedDate, matcher) {
end.minute(0);
end.second(0);
if (matcher.endMonth !== undefined) {
if (matcher.startMonth && matcher.startMonth > matcher.endMonth) {
if (matcher.startMonth
&& matcher.startMonth > matcher.endMonth
&& checkedDate.getMonth() > matcher.endMonth) {
end.year(checkedDate.getFullYear() + 1);
}
end.month(matcher.endMonth);
Expand Down

0 comments on commit 59fc568

Please sign in to comment.