[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fwd: Possible Bug in DateTime



Hi all,

mea culpa :)

Thanks for the answers.

Best regards,
Ulf

Am 09.10.2011 17:31, schrieb gregor herrmann:
> On Sun, 09 Oct 2011 11:14:10 -0400, Jonathan Yu wrote:
> 
>> Got this a month ago but had no time to take care of it myself. Can
>> one of you look at it? :-)
> 
>> ---------- Forwarded message ----------
>> From: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de>
>> Date: Mon, Sep 5, 2011 at 6:26 PM
>> Subject: Possible Bug in DateTime
>> To: jawnsy@cpan.org
>>
>>
>> Hello Jonathan,
> 
> Hi Ulf,
> 
> please file bug reports in the Debian BTS so the issues don't get
> lost in the future.
>  
>> # ==============
>> #!/usr/bin/perl
>> # script name: testdate.pl
>> use DateTime;
>> my $date = DateTime->now;
>> printf "Date: %s-%s\n",$date->year, $date->month;
>> # ==============
>>
>> ..going to Bash:
>> #> date
>> Di 6. Sep 00:09:18 CEST 2011
>> The script delivers correctly:
>> Date: 2011-9
>>
>> #> date
>> Do 1. Sep 00:09:15 CEST 2011
>> The script delivers wrongly:
>> Date: 2011-8
> 
> Well, that's 2011-08-31 22:09:15 UTC, so this smells like a timezone
> question.
>  
> 
> Trivial check:
> 
> #v+
> $ cat datetime.pl 
> #!/usr/bin/perl 
> 
> use DateTime;
> 
> my $date = DateTime->now;
> 
> printf "%s %s\n", $date->ymd, $date->hms;
> #v-
> 
> $ date
> Sun Oct  9 17:25:04 CEST 2011
> 
> $ perl datetime.pl 
> 2011-10-09 15:25:08
> 
> 
> Cf. also the documentation:
> 
>        ·   DateTime->now( ... )
>        
>            By default, the returned object will be in the UTC time zone.
> 
> 
> If you want DateTime to return dates/times in your local timezone,
> you have to tell it about it:
> 
> #v+
> $ cat datetime.pl 
> #!/usr/bin/perl 
> 
> use DateTime;
> 
> my $date = DateTime->now(time_zone => 'Europe/Vienna');
> 
> printf "%s %s\n", $date->ymd, $date->hms;
> #v-
> 
> $ date
> Sun Oct  9 17:30:11 CEST 2011
> 
> $ perl datetime.pl 
> 2011-10-09 17:30:14
> 
> Et voilà :)
> 
> 
> Cheers,
> gregor, mentally closing the non-existing bug
>                   

Viele Grüße,
Ulf Kreutzberg

-- 
Ulf Kreutzberg
Senior System Administrator Webhosting

E-Mail: ulf.kreutzberg@hosteurope.de
Telefon: +49 2203 1045-7355
Fax: +49 180 5 66 3233 (*)

-----------------------------------------------------------------------
Host Europe GmbH - http://www.hosteurope.de
Welserstraße 14 - 51149 Köln - Germany
Telefon: 0800 467 8387 - Fax: +49 180 5 66 3233 (*)
HRB 28495 Amtsgericht Köln - USt-IdNr.: DE187370678
Geschäftsführer: Patrick Pulvermüller, Thomas Vollrath

(*) 0,14 EUR/Min. aus dem dt. Festnetz; maximal 0,42 EUR/Min. aus
den dt. Mobilfunknetzen

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: