kepler has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date Timezone
by soonix (Chancellor) on Jul 16, 2017 at 14:22 UTC | |
|
Re: Date Timezone
by thanos1983 (Parson) on Jul 16, 2017 at 11:04 UTC | |
|
Re: Date Timezone
by Anonymous Monk on Jul 15, 2017 at 21:03 UTC | |
by kepler (Scribe) on Jul 15, 2017 at 23:29 UTC | |
by huck (Prior) on Jul 15, 2017 at 23:44 UTC | |
by 1nickt (Canon) on Jul 16, 2017 at 02:55 UTC | |
by stevieb (Canon) on Jul 16, 2017 at 01:19 UTC | |
by kepler (Scribe) on Jul 16, 2017 at 01:29 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |