On Wed, Apr 2, 2008 at 2:24 AM, Jeff Pang <[EMAIL PROTECTED]> wrote:
> On 4/2/08, Chas. Owens <[EMAIL PROTECTED]> wrote:
>  > On Wed, Apr 2, 2008 at 2:02 AM, Jeff Pang <[EMAIL PROTECTED]> wrote:
>  > > On 4/2/08, Richard Lee <[EMAIL PROTECTED]> wrote:
>  > >  > What is the best way to indicate past hour from current time without
>  > >  > using a module?
>  > >  >
>  > >  > so if it's 12:00, then 11:00-12:00
>  > >  >
>  > >
>  > >  I'd prefer using POSIX module since it's a built-in perl module.
>  > >  The code would be simple,
>  > >
>  > >  use strict;
>  > >  use POSIX 'strftime';
>  > >
>  > >  print get_time(time - 3600),"-",get_time(),"\n";
>  > >
>  > >  sub get_time {
>  > >     my $timestamp = shift || time;
>  > >     return strftime("%H:%M",localtime($timestamp));
>  > > }
>  >
>  > This is one of those seemingly simple questions that turns out to be
>  > much more complicated than you originally think.  For instance, what
>  > is one hour less than 2008-03-09 03:00:00?  If you answered 2008-03-09
>  > 02:00:00 you would be wrong in the USA as that hour does not exist.
>
>  It sounds strange to me.
>  Why 2008-03-09 02:00:00 doesn't exist for USA people?
>

Because of Daylight Saving Time.  Clocks are set from 01:59:59 to
03:00:00 on the second Sunday in March and from 01:59:59 to 01:00:00
on the first Sunday in November.

* http://en.wikipedia.org/wiki/Daylight_saving_time
-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to