$Bill Luebkert <> wrote:
> Mittal, Manish wrote:
> 
>> The timestap format is YYYY-DD-MM_HH:MM:SS
> 
> Next time you'll need to make your own attempt :
> 
> use strict;
> use warnings;
> use Time::Local;
> 
> my $date1 = ;
> my $date2 = '2005-06-06_01:02:03';
> 
> my $e1 = date2epoch ($date1);
> my $e2 = date2epoch ($date2);
> 
> my $diff = $e2 - $e1;
> 
> # you can format the difference any way you like or just use the
> value printf "diff: %u days, %u seconds\n", $diff / 86400, $diff %
> 86400; exit;  
> 
> sub date2epoch {
>       my $date = shift;
> 
> my @d = ();
> push @d, substr $date, 0, 4;  # using substr is probably fdastest
> method 
> push @d, substr $date, 5, 2;
> push @d, substr $date, 8, 2;
> push @d, substr $date, 11, 2;
> push @d, substr $date, 14, 2;
> push @d, substr $date, 17, 2;

Whether that is faster than "my @d = split /[-_:]/, $date;" I shall
leave up to Benchmark :)

> return timelocal $d[5], $d[4], $d[3], $d[2], $d[1] - 1, $d[0] - 1900;
> 
> }

If it really is a UTC time, then it might be better to call timegm
rather than timelocal.

HTH

-- 
Brian Raven





=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to