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 -- .''`. Homepage: http://info.comodo.priv.at/ - OpenPGP key ID: 0x8649AA06 : :' : Debian GNU/Linux user, admin, & developer - http://www.debian.org/ `. `' Member of VIBE!AT & SPI, fellow of Free Software Foundation Europe `- NP: Sting: Russians
Attachment:
signature.asc
Description: Digital signature