Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Bug in GT::Date?

Quote Reply
Bug in GT::Date?
Hi,

when I use date_add('2007-10-28', 1) the result is "2007-10-28".
To get "2007-10-29" as result, it must be date_add('2007-10-28', 2).

Same with following dates:
1980-09-28
1981-09-27
1982-09-26
1983-09-25
1984-09-30
1985-09-29
1986-09-28
1987-09-27
1988-09-25
1989-09-24
1990-09-30
1991-09-29
1992-09-27
1993-09-26
1994-09-25
1995-09-24
1996-10-27
1997-10-26
1998-10-25
1999-10-31
2000-10-29
2001-10-28
2002-10-27
2003-10-26
2004-10-31
2005-10-30
2006-10-29

I use Links 3.2.0.

Regards

Merten
Quote Reply
Re: [neves] Bug in GT::Date? In reply to
Hi,

I have the same problem too :( (wite GT::Date::date_is_valid() and date_add() / date_sub() ).

Apparently, its not a problem with the GT::Date module - but more how the date/time stuff is handled on servers. Bit of a PITA really :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [neves] Bug in GT::Date? In reply to
That happens because of daylight saving time. If you take the time October 28th, 12:00AM, add 24 hours to that, it makes it October 29th, 12:00AM. However, you lose an hour due to daylight saving at 2AM on the 28th, so it in fact the resulting date is October 28th, 11:00PM and not the 29th, 12:00AM.

Adrian
Quote Reply
Re: [brewt] Bug in GT::Date? In reply to
Ok, thanks.

I changed GT::Date::parse_format in line 731 to

Code:
if ( not defined( $hour ) ) {
$hour = 12;
}
elsif (!$pm and !$h24 and $hour == 12) {
$hour = 0;
}
if ($pm and $hour < 12) {
$hour += 12;
}

Now it works fine for me.

Regards

Merten
Quote Reply
Re: [neves] Bug in GT::Date? In reply to
Hi,

found another funny thing relating to GT::Date and daylight saving time:

date_diff( '2010-04-01', '2010-03-01' ) => 30

To get the correct count I changed

Code:
return int (($DATE_TO_TM{$key1} - $DATE_TO_TM{$key2}) / DAY);

in GT::Date::date_diff to

Code:
return sprintf( '%.0f', ($DATE_TO_TM{$key1} - $DATE_TO_TM{$key2}) / DAY);

Merten
Quote Reply
Re: [neves] Bug in GT::Date? In reply to
Hmm... I find it disappointing that this bugs still exists in 3.3.0. Don't you think it is a bug? Maybe it was not the right place to report it. Should I post it somewhere else?