[bcn-pm] Date, iCal, localtime
Xavier Noria
fxnahashref.com
Diu Ago 20 04:32:52 PDT 2006
On Aug 20, 2006, at 12:15 PM, Carles Pina i Estany wrote:
> Parseo un fichero que contiene las horas con:
> 20060821T080000Z (en UTC)
Mirant el codi del constructor no tinc clar que entengui
necessariament que esta en UTC:
# Date is specified as ical string#{{{
elsif ( defined( $args{ical} ) ) {
# Timezone, if any
$args{ical} =~ s/^(?:TZID=([^:]+):)?//;
$tz = $1;
# Split up ical string
( $year, $month, $day, $hour, $min, $sec, $zflag ) =
$args{ical} =~ /^(?:(\d{4})(\d\d)(\d\d))
(?:T(\d\d)?(\d\d)?(\d\d)?)?
(Z)?$/x;
# TODO: figure out what to do if we get a TZID.
# I'd suggest we store it for use by modules that care
# about TZID names. But we don't want this module
# to deal with timezone names, only offsets, I think.
# --srl
} #}}}
Es guarda el $tz, pero si no es passa un offset mes endavant fa aixo:
my $tz = $ENV{TZ} || '0';
my $loc = $tz eq $localzone ? $localoffset : _calc_local_offset();
$self->offset($loc) if defined $self;
de manera que no nomes ignora el TZID, sino que sembla que assumeix
la zona horaria definida a TZ.
Llevat que vagi errat, amb el llistat a la ma no acabo de veure fi
aquest modul pel que fa a zones horaries. Mireu per exemple:
feynman% cat ~/tmp/foo.pl
use Date::ICal;
$ENV{TZ} = 'CEST';
print Date::ICal->new(ical=>"TZID=US-Eastern:20060821T080000")->ical
(localtime => 1), "\n";
feynman% perl ~/tmp/foo.pl
20060821T080000
-- fxn
Més informació de la llista de correu Barcelona-pm