Added Paul's changes to the version that should be current. I have been having problems with my version reverting back to an old

one.
This commit is contained in:
wolfpac444 2003-04-03 01:28:28 +00:00
parent 5bbd7abd9c
commit a5587ab3a2

View file

@ -17,10 +17,10 @@ $VERSION = 0.01;
@EXPORT = qw( @EXPORT = qw(
&display_date_format &display_date_format
&format_date &format_date
&format_date_in_iso
); );
sub get_date_format sub get_date_format
{ {
#Get the database handle #Get the database handle
@ -31,7 +31,7 @@ sub get_date_format
sub display_date_format sub display_date_format
{ {
my $dateformat = get_date_format(); my $dateformat = get_date_format();
if ( $dateformat eq "us" ) if ( $dateformat eq "us" )
{ {
return "mm/dd/yyyy"; return "mm/dd/yyyy";
@ -60,16 +60,19 @@ sub format_date
if ( $dateformat eq "us" ) if ( $dateformat eq "us" )
{ {
Date_Init("DateFormat=US");
$olddate = ParseDate($olddate); $olddate = ParseDate($olddate);
$newdate = UnixDate($olddate,'%m/%d/%Y'); $newdate = UnixDate($olddate,'%m/%d/%Y');
} }
elsif ( $dateformat eq "metric" ) elsif ( $dateformat eq "metric" )
{ {
Date_Init("DateFormat=metric");
$olddate = ParseDate($olddate); $olddate = ParseDate($olddate);
$newdate = UnixDate($olddate,'%d/%m/%Y'); $newdate = UnixDate($olddate,'%d/%m/%Y');
} }
elsif ( $dateformat eq "iso" ) elsif ( $dateformat eq "iso" )
{ {
Date_Init("DateFormat=iso");
$olddate = ParseDate($olddate); $olddate = ParseDate($olddate);
$newdate = UnixDate($olddate,'%Y-%m-%d'); $newdate = UnixDate($olddate,'%Y-%m-%d');
} }
@ -79,4 +82,35 @@ sub format_date
} }
} }
sub format_date_in_iso
{
my $olddate = shift;
my $newdate;
my $dateformat = get_date_format();
if ( $dateformat eq "us" )
{
Date_Init("DateFormat=US");
$olddate = ParseDate($olddate);
}
elsif ( $dateformat eq "metric" )
{
Date_Init("DateFormat=metric");
$olddate = ParseDate($olddate);
}
elsif ( $dateformat eq "iso" )
{
Date_Init("DateFormat=iso");
$olddate = ParseDate($olddate);
}
else
{
return "9999-99-99";
}
$newdate = UnixDate($olddate, '%Y-%m-%d');
return $newdate;
}
1; 1;