datetime comparisons

2005-04-05 Thread John
hello all

i am wondering a there is a module that do comparisons
between two different datetime stamps

for example

2/4/2005:15:20:20 and 4/4/2005:12:09:23

which date is bigger (namely earliest)





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: datetime comparisons

2005-04-05 Thread Moon, John
Subject: datetime comparisons

hello all

i am wondering a there is a module that do comparisons
between two different datetime stamps

for example

2/4/2005:15:20:20 and 4/4/2005:12:09:23

which date is bigger (namely earliest)



You may wish to look at Time::Local. This will convert the strings to
seconds then they can be compared...

Hope this gives you some ideas...

jwm



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: datetime comparisons

2005-04-05 Thread Peter Rabbitson
On Tue, Apr 05, 2005 at 04:12:31PM +0300, John wrote:
 hello all
 
 i am wondering a there is a module that do comparisons
 between two different datetime stamps
 
 for example
 
 2/4/2005:15:20:20 and 4/4/2005:12:09:23
 
 which date is bigger (namely earliest)
 

I was down this road some time ago myself - definitely DateTime by Dave
Rolsky. While it is not the most compact and not the fastest solution it has
it all. Saved me way too many time from reinventing the wheel. On the other
hand if your application is rather small and is guaranteed to stay small
(which is usually not the case) you might look into other possibilities like
simple numerical acrobatics with Time::Local (e.g. converting everything to
epoch seconds and working from there). 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re[2]: datetime comparisons

2005-04-05 Thread John

From: Peter Rabbitson [EMAIL PROTECTED]
To: beginners@perl.org
Date: Tuesday, April 5, 2005, 5:03:09 PM
Subject: datetime comparisons



  Tuesday, April 5, 2005, 5:03:09 PM, you wrote:

   On Tue, Apr 05, 2005 at 04:12:31PM +0300, John wrote:
 hello all
 
 i am wondering a there is a module that do comparisons
 between two different datetime stamps
 
 for example
 
 2/4/2005:15:20:20 and 4/4/2005:12:09:23
 
 which date is bigger (namely earliest)
 

 I was down this road some time ago myself - definitely DateTime by Dave
 Rolsky. While it is not the most compact and not the fastest solution it has
 it all. Saved me way too many time from reinventing the wheel. On the other
 hand if your application is rather small and is guaranteed to stay small
 (which is usually not the case) you might look into other possibilities like
 simple numerical acrobatics with Time::Local (e.g. converting everything to
 epoch seconds and working from there). 



DateTime helped and me.

The comparison is made easy with two datetime objects.

Thanks



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: datetime comparisons

2005-04-05 Thread John W. Krahn
John wrote:
hello all
Hello,
i am wondering a there is a module that do comparisons
between two different datetime stamps
for example
2/4/2005:15:20:20 and 4/4/2005:12:09:23
which date is bigger (namely earliest)
Probably the easiest way is to convert them to comparable strings:
my ( $date1, $date2 ) = ( '2/4/2005:15:20:20', '4/4/2005:12:09:23' );
# I assume the date is m/d/y:h:m:s?
my $cmp1 = sprintf '%04d%02d%02d%02d%02d%02d', ( $date1 =~ /\d+/g )[ 
2,0,1,3,4,5 ];
my $cmp2 = sprintf '%04d%02d%02d%02d%02d%02d', ( $date2 =~ /\d+/g )[ 
2,0,1,3,4,5 ];

if ( $cmp1 gt $cmp2 ) {
do_something();
}

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response