Gossamer Forum
Home : Products : DBMan : Customization :

small Date porblem

Quote Reply
small Date porblem
Hi,
I have a small issue which is driving me mad. I have a routine which creates a number of continuos/consecutive dates which works well except for one small problem, it produced one day/date twice eg.25/03/2007. I don't know why this is happening for this one day of the year. What am I missing here.
Any help would be great full.
eg. example of the output.
1,b,Smith,John,02/01/2007,5
2,b,Smith,John,03/01/2007,
.
.
81,b,Smith,John,23/03/2007,
82,b,Smith,John,24/03/2007,
83,b,Smith,John,25/03/2007,
84,b,Smith,Johnhn,25/03/2007,
85,b,Smith,John,26/03/2007,

Here is my code.
sub html_build_totals_record {
# --------------------------------------------------------
#
#
&html_print_headers;
$cnta = $i;
$cntb = 8;
$cntv = 1;
$staff_file = ("$db_csv_path").("staff_totals").(".csv");
open (DB, "<$staff_file") or &cgierr("error in count. unable to open database: $staff_file.\nReason: $!");
if ($db_use_flock) { flock(DB,1); }
@lines = <DB>;
close DB;
foreach $line (@lines) {
chomp ($line);
@data = &split_decode($line);
$userid = $data[0];
$userlast = $data[1];
$userfirst = $data[2];
&html_build_lines;
}
}
sub html_build_lines {
$in{'end_date'} = &date_to_unix("25-Dec-2006");
for ($i = 8; $i<=208; ++$i) {
$diff = &get_date_new;
print qq| $cntv,$userid,$userlast,$userfirst,$diff,$data[$i] <br> |;
++$cntv;
++$cntb;
}
}

sub get_date_new {
# --------------------------------------------------------
# Returns the date in the format "yyyy-mm-dd".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.
my ($time) = $in{'end_date'};
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(($time+86400*$i));
my (@months) = qw!01 02 03 04 05 06 07 08 09 10 11 12!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

# return "$year-$months[$mon]-$day";
return "$day/$months[$mon]/$year";
}