Skip to content
Snippets Groups Projects
Commit 7a51709e authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Fixed stepping of days by months or years to work in a more useful way.

Previously e.g. Calendar.ISO.Day(2000,1,31)+Calendar.ISO.Month() would
return March 2nd since there aren't 31 days in February and the Calendar
module would instead step 30 days forward from February 1st.

This is counterintuitive and not useful in most cases; practice shows that
it's clearly better to keep the month correct and accept an offset in the
day-of-month, i.e. to get February 29th instead in the example above.

The same situation also exists when standing on a leap day and stepping by
years to a non-leap year. This patch fixes that case too.

It does however not fix stepping weeks by years, which currently works in an
inconsistent way wrt to days. That will be fixed in versions >= 7.7 with
compat goo.

NOTE: This change is not strictly compatible, but given the alternatives of
introducing a theoretical incompatibility and solving a very real and
repeatedly encountered problem, the choice isn't difficult.

Rev: lib/modules/Calendar.pmod/YMD.pike:1.28
Rev: lib/modules/Calendar.pmod/testsuite.in:1.16
parent 7b64ef07
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment