I'm having some troubles making a sub function that given an year, month, day and hour and the zone would return the offset in seconds. The general code is this (and works if used in the main routine):
my $tz = DateTime::TimeZone->new( name => $zone ); my $dt = DateTime->new( year => $year_init, month => $month_init, day => $day_init, hour => $hour_init, minute => $minutes_init, second => $seconds_init, nanosecond => 0, ); $offset = $tz->offset_for_datetime($dt); #seconds $offset_days = $offset / 86400; #days
BUT if I place it in a function, let's say sub TZone (), where I receive all the parameters, the program does not give an error but exits (I say this because no more output is done...). If I make a return before the above, it returns what I want (so the function is well formated, except when it calls the offset). Can someone help me out?
Kind regards, Kepler
In reply to Date Timezone by kepler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |