#!/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); }