Gossamer Forum
Home : Products : DBMan : Customization :

Help with date for auto delete

Quote Reply
Help with date for auto delete
Today I found why my Auto Delete is mod is not working...

actually I did change the time for &get_date; because I need this to be in such format to insert into the database.

Current format: Aug-05-03

#####################

sub
get_date {

# Warning: If you change the default format, you must also modify the &date_to_unix, HOW?????


my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my (@months) =
qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day =
"0$day");
$year = $year + 1900;

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


#######################



But for Auto Delete

my
$today = &date_to_unix(&get_date);

I never changed the &date_to_unix;

########################

Now my question is what changes should be made to &date_to_unix;

to work along with current date format i.e. Aug-05-03

I am also posting unchanged sub date_to_unix

#######################

sub
date_to_unix {
my ($date) = $_[0];
my (%months) = (
"Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4, "Jun" => 5,
"Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9, "Nov" => 10,"Dec" => 11);
my ($time);
my ($day, $mon, $year) = split(
/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }

use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900;
$time = timelocal(0,0,0,$day, $months{$mon}, $year);
};
if ($@) { return undef; }
# Could return 0 if you want.
return ($time);
}


#############################



Thanks for any input,



Zeshan.


Subject Author Views Date
Thread Help with date for auto delete zeshan 3000 Aug 4, 2003, 9:03 PM
Thread Re: [zeshan] Help with date for auto delete
LoisC 2963 Aug 5, 2003, 12:36 AM
Thread Re: [LoisC] Help with date for auto delete
zeshan 2962 Aug 5, 2003, 3:05 PM
Post Re: [zeshan] Help with date for auto delete
LoisC 2917 Aug 6, 2003, 2:13 AM