From a5587ab3a2647f9236ef272a9ae7dd826e6c4acb Mon Sep 17 00:00:00 2001 From: wolfpac444 Date: Thu, 3 Apr 2003 01:28:28 +0000 Subject: [PATCH] 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. --- C4/Date.pm | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/C4/Date.pm b/C4/Date.pm index 69bf744209..c7ddfc405e 100644 --- a/C4/Date.pm +++ b/C4/Date.pm @@ -17,10 +17,10 @@ $VERSION = 0.01; @EXPORT = qw( &display_date_format &format_date + &format_date_in_iso ); - sub get_date_format { #Get the database handle @@ -31,7 +31,7 @@ sub get_date_format sub display_date_format { my $dateformat = get_date_format(); - + if ( $dateformat eq "us" ) { return "mm/dd/yyyy"; @@ -60,16 +60,19 @@ sub format_date if ( $dateformat eq "us" ) { + Date_Init("DateFormat=US"); $olddate = ParseDate($olddate); $newdate = UnixDate($olddate,'%m/%d/%Y'); } elsif ( $dateformat eq "metric" ) { + Date_Init("DateFormat=metric"); $olddate = ParseDate($olddate); $newdate = UnixDate($olddate,'%d/%m/%Y'); } elsif ( $dateformat eq "iso" ) { + Date_Init("DateFormat=iso"); $olddate = ParseDate($olddate); $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; -- 2.39.5