FYI, I can't replicate the problem. I always get 6 days apart, even with 11/1/2008 (and even when pretending to be in another time zone, e.g. via TZ=PST). Not really sure if it might have to do with the timezone, but maybe you could just try by switching to timegm()/gmtime() (and $ENV{TZ}="GMT", as strftime is TZ-aware). Or maybe your system's POSIX library (strftime) is just broken...
Update: actually, I can reproduce the issue when using a time zone for which my system does handle daylight savings time1 (plus using a different start date, as in (most parts of) Europe the DST switch is done on the last Sunday in October — as opposed to the first Sunday in November). Similarly, using TZ=GMT 'fixes' the issue:
$ TZ=CET ./727202.pl -s 10/25/2008 The start day is 10/25/2008 and the end day is 10/30/2008 23:00 $ TZ=GMT ./727202.pl -s 10/25/2008 The start day is 10/25/2008 and the end day is 10/31/2008 00:00
(to show the hour, I changed the end_day format to "%m/%d/%Y %H:%M")
Anyhow, as others have said, it's probably better to use a module that has already solved this, and other date/time issues...
___
1 For reasons I haven't investigated further, it isn't sufficient to set my TZ to a time zone in the US — when doing so, I do get the respective local time, but without the local daylight savings time being handled correctly... (which is why I initially couldn't replicate the problem)
In reply to Re: date string conundrum
by almut
in thread date string conundrum
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |