bazz
06-02-2008, 05:36 AM
Hi,
Modifying a sub routine, to try to compare dates. converted to timestamp but division by 86400 , to get a 'daily stamp' seems to make no difference to the original timestamp.
here's the code
my $check_in_date = 2008-05-15
my $check_out_date = 2008-05-07
sub get_day_status {
my $check_in = shift;
my $check_out = shift;
my $currdate = shift;
my $check_in_timestamp = build_timestamp($check_in);
my $check_out_timestamp = build_timestamp($check_out);
my $currdate_timestamp = build_timestamp($currdate);
print qq(
cits=$check_in_timestamp <br />
cots=$check_out_timestamp <br />
cdts=$currdate_timestamp <br />
);
if($currdate_timestamp >= $check_in_timestamp && $currdate_timestamp < $check_out_timestamp)
{
# my ($before, $after) = get_date_interval($check_in,$check_out);
# if($currdate >= $before && $currdate < $after){
print qq( unavailable);
return 'unavailable';
}
else
{
print q( available);
return 'available';
}
}
# build a unix timestamp
sub build_timestamp {
$iso_date = shift;
# parse and convert date to unix time
my $timestamp = str2time($iso_date);
my $newtimestamp = ($timestamp/86400);
return $newtimestamp;
}
The $currdate is set for each day of a month in a loop.
stumped on this one. :(
bazz
Modifying a sub routine, to try to compare dates. converted to timestamp but division by 86400 , to get a 'daily stamp' seems to make no difference to the original timestamp.
here's the code
my $check_in_date = 2008-05-15
my $check_out_date = 2008-05-07
sub get_day_status {
my $check_in = shift;
my $check_out = shift;
my $currdate = shift;
my $check_in_timestamp = build_timestamp($check_in);
my $check_out_timestamp = build_timestamp($check_out);
my $currdate_timestamp = build_timestamp($currdate);
print qq(
cits=$check_in_timestamp <br />
cots=$check_out_timestamp <br />
cdts=$currdate_timestamp <br />
);
if($currdate_timestamp >= $check_in_timestamp && $currdate_timestamp < $check_out_timestamp)
{
# my ($before, $after) = get_date_interval($check_in,$check_out);
# if($currdate >= $before && $currdate < $after){
print qq( unavailable);
return 'unavailable';
}
else
{
print q( available);
return 'available';
}
}
# build a unix timestamp
sub build_timestamp {
$iso_date = shift;
# parse and convert date to unix time
my $timestamp = str2time($iso_date);
my $newtimestamp = ($timestamp/86400);
return $newtimestamp;
}
The $currdate is set for each day of a month in a loop.
stumped on this one. :(
bazz