In DBMan I have modified the "date_to_unix" sub and created a new one called "date_to_screen". The purpose of this is to modify the date string originally in this format: 03/04/2000
(It is different than the normal format used by DBMan)
to this format: March 4, 2000
But it does not seem to work, can anybody help me debug why it is not doing it correctly?
# --------------------------------------------------------
# Comments removed for space considerations.
my ($date) = $_[0];
my (%months) = ("January" => 1, "February" => 2, "March" => 3, "April" => 4,
"May" => 5, "June" => 6, "July" => 7, "August" => 8,
"September" => 9, "October" => 10, "November" => 11,
"December" => 12);
my ($time);
my ($mon, $day, $year) = split(///, $_[0]);
unless ($mon and $day and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }
eval {
$day = int($day); $year = int($year); $mon = int($mon);
$time = '$months{$mon} $day, $year';
};
if ($@) { return undef; } # Could return 0 if you want.
return ($date);
}
Any Ideas?
(It is different than the normal format used by DBMan)
to this format: March 4, 2000
But it does not seem to work, can anybody help me debug why it is not doing it correctly?
Code:
sub date_to_screen { # --------------------------------------------------------
# Comments removed for space considerations.
my ($date) = $_[0];
my (%months) = ("January" => 1, "February" => 2, "March" => 3, "April" => 4,
"May" => 5, "June" => 6, "July" => 7, "August" => 8,
"September" => 9, "October" => 10, "November" => 11,
"December" => 12);
my ($time);
my ($mon, $day, $year) = split(///, $_[0]);
unless ($mon and $day and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }
eval {
$day = int($day); $year = int($year); $mon = int($mon);
$time = '$months{$mon} $day, $year';
};
if ($@) { return undef; } # Could return 0 if you want.
return ($date);
}
Any Ideas?