On Wed, Mar 26, 2008 at 11:34 AM, Ewald Beekman <[EMAIL PROTECTED]> wrote:
> Is there a way to see if DST is in effect on a
>  returned time zone object ?
>  For instance, i have got a loop like this:
>
>  my @list = DateTime::TimeZone->all_names;
>  foreach $zone (@list) {
>         next unless ($zone =~ /\//);                    # skip timezone links 
> in the list
>         $dt = DateTime->now();                          # current computer 
> time
>         $tz = DateTime::TimeZone->new( name => $zone ); # timezone
>
>         $offset = $tz->offset_for_datetime($dt);        # offset from UTC for 
> this timezone
>         $TZ = $tz->short_name_for_datetime($dt);        # timezone name (e.g. 
> CET)
>         $dt->add(seconds =>  $offset);                  # convert computer 
> time to time in timezone
>         $hoffset = $offset / 3600;                      # offset in hours
>
>         printf "%40s\t%s\tGMT diff = %g\t%4s\t",$zone,$TZ, $hoffset,$DST;
>         printf "%d/%02d/%02d 
> %02d:%02d\n",$dt->year,$dt->month,$dt->day,$dt->hour,$dt->minute;
>         }
>
>  How can i see for each zone displayed if it is in DST?

is_dst() method does it for you.

  if ($dt->clone->set_time_zone($tz)->is_dst) {
       # it's in DST now
  }

HTH

Reply via email to