[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60671] Wrong result when subtracting one mont
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #60671] Wrong result when subtracting one month from 31-MON-YEAR date |
Date: |
Tue, 25 May 2021 11:56:46 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0 |
Follow-up Comment #3, bug #60671 (project octave):
I think changing changing lines 65 and 66 in addtodate.m to the following
loops will be safer. Is this OK for edge cases?
do
ii = (dtmp(:,2) < 1); # these entries are underflowing
dtmp(ii,2) += 12; # go from Month 0 to Month 12, etc
dtmp(ii,1) -= 1; # and decrement year
until (~any(ii));
do
ii = (dtmp(:,2) > 12); # these entries are overflowing
dtmp(ii,2) -= 12; # go from Month 13 to Month 1, etc
dtmp(ii,1) += 1; # and increment year
until (~any(ii));
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60671>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/