Hi,
There is something weird going on with date->subtract. This time it concerns Lasso 9.2.5 AND Lasso 8.6.0.1
We bumped into it when we ran my standard testpage for my date-routine. It showed a 1-day difference on only 1 line with L9 vs L8.
So for the sake of it, I built a loop (see below) to test the date->subtract at the turn of a year, and that showed the bug in Lasso8.
Also, I ran the loop from 1999 thru 2012 and the bug is always at the same dates:
L8: always December 01 when subtracting from January 7 or 8
L9: always November 23 when subtracting from December 30 and 31
Also, what is strange, is that with leapyears, the dates should at least be December 02 and November 24. ??
First, the Lasso8 code where we discovered a bug:
date_format(date_subtract(date('20000107213000'), -month=1, -week=1, -minute=10), -format='%Y%m%d %H%M%S');
'<br>';
date_format(date_subtract(date('20000108213000'), -month=1, -week=1, -minute=10), -format='%Y%m%d %H%M%S');
output:
19991201 212000
19991201 212000
Then Lasso9, where we discovered the same bug, but at another date:
date_format(date_subtract(date('19991230213000'), -month=1, -week=1, -minute=10), -format='%Y%m%d %H%M%S');
'<br>';
date_format(date_subtract(date('19991231213000'), -month=1, -week=1, -minute=10), -format='%Y%m%d %H%M%S');
output:
19991123 212000
19991123 212000
We found this by running the following loop:
----------------------------------------------------------------------
Lasso8:
----------------------------------------------------------------------
[
local(
'date1' = array(1999,12,25,213000),
'date2' = ''
);
'<pre>';
loop(50);
#date1->get(2)->setformat(-padding=2, -padchar='0', -padright=false);
#date1->get(3)->setformat(-padding=2, -padchar='0', -padright=false);
#date2 = #date1->get(1) + string(#date1->get(2)) + string(#date1->get(3)) + string(#date1->get(4));
#date2;'<br>';
date_format(date_subtract(date(#date2), -month=1, -week=1, -minute=10), -format='%Y%m%d %H%M%S');
'<br>- - -<br>';
// To perform a clean test, I add a day myself.
#date1->get(3) += 1;
if(#date1->get(3) > 31);
#date1->get(3) = 1;
#date1->get(2) += 1;
if(#date1->get(2) > 12);
#date1->get(2) = 1;
#date1->get(1) += 1;
/if;
/if;
/loop;
'</pre>';
]
----------------------------------------------------------------------
Lasso9:
----------------------------------------------------------------------
[
local(
'date1' = array(1999,12,25,213000),
'date2' = ''
);
'<pre>';
loop(50);
#date2 = #date1->get(1) + #date1->get(2)->asstring(-padding=2, -padchar='0', -padright=false) + #date1->get(3)->asstring(-padding=2, -padchar='0', -padright=false) + string(#date1->get(4));
#date2;'<br>';
date_format(date_subtract(date(#date2), -month=1, -week=1, -minute=10), -format='%Y%m%d %H%M%S');
'<br>- - -<br>';
// To perform a clean test, I add a day myself.
#date1->get(3) += 1;
if(#date1->get(3) > 31);
#date1->get(3) = 1;
#date1->get(2) += 1;
if(#date1->get(2) > 12);
#date1->get(2) = 1;
#date1->get(1) += 1;
/if;
/if;
/loop;
'</pre>';
]
Can others confirm this?
Maybe also with other years that they know of?
- -
Cheers,
Marc
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>