mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-11 11:56:16 +01:00
Fix the 6-days-until-the-end-of-the-month bug
The addition causes the date to shift forward into 1st of the next month, because a 0-based offset is compared to be "more than" the days in the month instead of "more than or equal to". This is triggered by corner-cases where transition date is 6 days off the end of the month and our calculations put it at N+1th day of the month (where N is the number of days in the month). The subtraction should be triggered to move the date back a week, putting it 6 days off the end; for example, October 25 for CET DST transition; but due to incorrect comparison the date isn't shifted back, we add 31 days to October 1st and end up at November 1st). Fixes issue #2215.
This commit is contained in:
parent
411aa46401
commit
da00779093
@ -1041,7 +1041,11 @@ find_relative_date (TimeZoneDate *buffer)
|
||||
/* week is 1 <= w <= 5, we need 0-based */
|
||||
days = 7 * (buffer->week - 1) + wday - first_wday;
|
||||
|
||||
while (days > days_in_month)
|
||||
/* "days" is a 0-based offset from the 1st of the month.
|
||||
* Adding days == days_in_month would bring us into the next month,
|
||||
* hence the ">=" instead of just ">".
|
||||
*/
|
||||
while (days >= days_in_month)
|
||||
days -= 7;
|
||||
|
||||
g_date_add_days (&date, days);
|
||||
|
Loading…
Reference in New Issue
Block a user