Skip to content

Commit

Permalink
Fix content end date if already in new year (#15376)
Browse files Browse the repository at this point in the history
* Fix content end date if already in new year

* fix test
  • Loading branch information
phillipthelen authored Jan 2, 2025
1 parent aa43202 commit 62e6fbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/api/v3/integration/debug/POST-debug_jumpTime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('POST /debug/jump-time', () => {
expect(resultDate.getDate()).to.eql(today.getDate());
expect(resultDate.getMonth()).to.eql(today.getMonth());
expect(resultDate.getFullYear()).to.eql(today.getFullYear());
const newResultDate = new Date((await user.post('/debug/jump-time', { offsetDays: 355 })).time);
const newResultDate = new Date((await user.post('/debug/jump-time', { offsetDays: 365 })).time);
expect(newResultDate.getFullYear()).to.eql(today.getFullYear() + 1);
});

Expand Down
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 62e6fbe

Please sign in to comment.