Gossamer Forum
Home : Gossamer Threads Inc. : Discussion :

GT::Date - Determining whether it is before a particular time

Quote Reply
GT::Date - Determining whether it is before a particular time
Quote:
Hi,

(I think that this is the appropriate forum for discussing the GT:: Modules, despite the forum description).

I'm trying to determine whether or not the time is before 6pm using GT::Date, but at the moment neither date_is_greater or date_is_smaller returns true. Any ideas how I can overcome this (or what I'm doing wrong?)

Code:
#!/usr/bin/perluse GT::Date qw/:all/;my $days = 4;##### Time Formats ################
$sec_fmt = '%HH%:%MM%:%ss%';
$orig_fmt = '%yyyy%-%mm%-%dd% %HH%:%MM%:%ss%';
###############################
date_set_format($orig_fmt);my $date = date_get();
my $deadline = date_get (time + ($days * 86400)); print qq|Order Date: $date
Deadline: $deadline
|;# If the time is after 6:00pm, then we should give everyone an extra day as it's
# so late in the day.
$now_s = date_transform ($date, $orig_fmt, $sec_fmt);
$sixpm_s = '18:00:00';
date_set_format($sec_fmt); print "Comparing $now_s with $sixpm_s\n";
if (date_is_greater($sixpm_s, $now_s)) {
print "It is after 6pm ($sixpm_s > $now_s )\n";
}
if (date_is_smaller($sixpm_s, $now_s)) {
print "It is before 6pm ($now_s < $sixpm_s)\n";
}
From the GT::Date docs:
Quote:
date_is_greater[/url]

Returns 1 if argument 1 is greater then argument 2, otherwise 0.


date_is_smaller[/url]

Returns 1 if argument 1 is smaller then argument 2, otherwise 0.

Last edited by:

cwi: Aug 27, 2003, 1:31 PM
Subject Author Views Date
Thread GT::Date - Determining whether it is before a particular time cwi 4410 Aug 27, 2003, 1:29 PM
Post Re: [cwi] GT::Date - Determining whether it is before a particular time
cwi 4279 Aug 27, 2003, 1:31 PM
Thread Re: [cwi] GT::Date - Determining whether it is before a particular time
Alex 4298 Aug 27, 2003, 2:12 PM
Post Re: [Alex] GT::Date - Determining whether it is before a particular time
cwi 4276 Aug 27, 2003, 2:16 PM