On Thu, Apr 18, 2013 at 01:00:38AM +0100, Ricardo Pais Oliveira wrote: > Hi!
Hello, > I'm using DateTime::TimeZone to get my current time. Shouldn't daylight > saving time be handled by the DateTime module? > > In $date I'm obtaining the time with less an hour than it should so I > believe DST is not being considered. How can I obtain the current time > regardless it's in DST mode or not? > > Here's my script: > > use 5.14.2; > use warnings; Using the warnings pragma is good! You should also use the strict pragma: use strict; > use DateTime::TimeZone; > > my $tz = DateTime::TimeZone->new( name => 'Europe/Lisbon' ); > my $date = DateTime->now(); > print $date; Looks to me like the problem is that you're not specifying the time zone for DateTime::now. Try this: my $date = DateTime->now(time_zone => $tz); Seems to work on my end. Regards, -- Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org> Castopulence Software <https://www.castopulence.org/> Blog <http://www.bamccaig.com/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'
signature.asc
Description: Digital signature