First, welcome at the Monastery. There are a couple of issues with your code, but as it's time to go to bed in my local TZ, I hope some other kind monks will point them out :)
Anyhow, if the idea is to convert those dates (with any TZ) into EST, the whole thing can be simplified considerably, because Date::Manip already does most of the magic while parsing the input string...
#!/usr/bin/perl -w use strict; use Date::Manip; Date_Init("TZ=EST"); # target TZ # use your filehandle here instead of DATA while (my $date_anyTZ = <DATA>) { chomp $date_anyTZ; # get rid of '~' to make date parseable by Date::Manip $date_anyTZ =~ tr/~/ /; my $date_EST = UnixDate(ParseDate($date_anyTZ), "%Y-%m-%d %H:%M:%S + %Z"); printf "%-24s --> %s\n", $date_anyTZ, $date_EST; } __DATA__ 20050526~18:15:06 GMT 20040401~01:12:02 GMT 20060201~00:59:01 GMT 20060401~01:01:01 EST 20040201~10:10:01 -0600 20010901~04:23:05 -0400 20050526~18:15:06 GMT 20040401~01:12:02 GMT 20000101~00:59:01 -0200 19841223~04:22:06 MST
Prints
20050526 18:15:06 GMT --> 2005-05-26 13:15:06 EST 20040401 01:12:02 GMT --> 2004-03-31 20:12:02 EST 20060201 00:59:01 GMT --> 2006-01-31 19:59:01 EST 20060401 01:01:01 EST --> 2006-04-01 01:01:01 EST 20040201 10:10:01 -0600 --> 2004-02-01 11:10:01 EST 20010901 04:23:05 -0400 --> 2001-09-01 03:23:05 EST 20050526 18:15:06 GMT --> 2005-05-26 13:15:06 EST 20040401 01:12:02 GMT --> 2004-03-31 20:12:02 EST 20000101 00:59:01 -0200 --> 1999-12-31 21:59:01 EST 19841223 04:22:06 MST --> 1984-12-23 06:22:06 EST
which looks OK to me.
In reply to Re: TimeZone Assistance Requested
by almut
in thread TimeZone Assistance Requested
by Knoperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |