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
####
#!/usr/bin/perl -w
use strict;
use Date::Manip;
Date_Init("TZ=EST"); #set TimeZone to Eastern Daylight Savings Time
{
my $input = $ARGV[0]; #returns filename from command line
my $thetmz; #time zone for that line
my ( $date, $time); #from file
chomp $input; #strip the carriage return
sub convertthetmz {
$datetime = ( "$date" . "$time" )
; #$date and #time from subroutine call and concats them
$converteddate = ParseDate("$datetime"); #date-time strng
$converteddate =Date_ConvTZ("$converteddate", $thetmz, "EST" )
; #converts from any tmz to EST
print("$converteddate~$from~$to\n");
}
open( DATAFILE, "$input" )
|| die("Can not open $input:!\n"); #access the file
while () {
chomp $_;
( $date, $time) = split( "~", $_ ); #split date/time
my $testfortmz = substr $time, -3; #last 4 chars of str
if ( "$testfortmz" == "-0400" ) {
$thetmz = "AST";
convertthetmz( $thetmz, $date, $time, $from, $to );
}
elsif ( "$testfortmz" == "-0600" ) {
$thetmz = "CST";
convertthetmz( $thetmz, $date, $time, $from, $to );
}
elsif ( "$testfortmz" =~ " GMT" ) {
$thetmz = "GMT";
convertthetmz( $thetmz, $date, $time, $from, $to );
}
else #this is need to work for some reason
{
my $nochangedate;
$nochangedate = ( ParseDate("$date.$time") );
print("$nochangedate~$from~$to\n");
}
}
close(DATAFILE);
}
####
2005052613:15:06
2004033120:12:02
2006013119:59:01
2006040101:01:01
2004020112:10:01
2001090102:23:05
2005052613:15:06
2004033120:12:02
1999123121:59:01
1984122306:22:06