Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeperiods: fix off by one when calculating n-th last weekday of the month #10133

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

Al2Klimov
Copy link
Member

@cla-bot cla-bot bot added the cla/signed label Aug 21, 2024
@icinga-probot icinga-probot bot added area/runtime Downtimes, comments, dependencies, events bug Something isn't working labels Aug 21, 2024
@icinga-probot icinga-probot bot added this to the 2.13.10 milestone Aug 21, 2024
… month

A day specification like "monday -1" refers to the last Monday of the month.
However, there was an off by one if the first day of the next month is the same
day of the week, i.e. a Monday in this example.

LegacyTimePeriod::FindNthWeekday() picks a day to start the search for the day
in question. When given a negative n to search for the n-th last day, it
wrongly used the first day of the following month as the start and counted it
as if it was within the current month. This resulted in a 1/7 chance that the
result was one week too late.

This is fixed by using the last day of the current month instead.
@Al2Klimov Al2Klimov force-pushed the timeperiod-nth-day-of-month-off-by-one-2.13 branch from 146100f to 6986417 Compare September 17, 2024 14:44
@yhabteab yhabteab merged commit 1938268 into support/2.13 Sep 18, 2024
26 checks passed
@yhabteab yhabteab deleted the timeperiod-nth-day-of-month-off-by-one-2.13 branch September 18, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime Downtimes, comments, dependencies, events bug Something isn't working cla/signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants