Good morning All. I am looking for a way to translate date/timestamps in various formats to EPOCH seconds without using a module (cannot use a module in this situation other then the standard modules installed with Perl).
I am going to create a subroutine and parse the date/timestamp passed into it's various components. I will then pass those components to the timelocal function to return the EPOCH seconds. Ex: $dayOfWeek, $day, $month, $hour, $min, $sec, $year=split /\s+|:/, $_[0]; my %months=qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11); $month=$months{$month}; $time=timelocal($sec,$min,$hour,$day,$month,$year); The problem is, the date/timestamp passed can be of various formats: Ex: Tuesday, 04/26/2005 06:02:43 PM Tuesday, 26/04/2005 18:02:43 04/26/2005 06:02:43 PM 26/04/2005 06:02:43 PM 04/26/2005 18:02:43 etc.. I am looking for a way to gracefully handle the format using a format parameter passed with the date/timstamp to the subroutine. Ex. my $epoch=convert_to_epoch("Tuesday, 26/04/2005 18:02:43","Day, DD/MM/YYYY HH24:MM:SS") my $epoch=convert_to_epoch("04/26/2005 06:02:43 PM" ,"DD/MM/YYY HH12:MM:SS") Is there a gracefull way of doing this WITHOUT using if if/elsif loop to parse every possible format type? Again, I cannot use a module in this situation due to limitations of the runtime environment. Thanks! Jason -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>