Added format_date_in_iso function.
authorwolfpac444 <wolfpac444>
Wed, 26 Mar 2003 03:57:10 +0000 (03:57 +0000)
committerwolfpac444 <wolfpac444>
Wed, 26 Mar 2003 03:57:10 +0000 (03:57 +0000)
C4/Date.pm

index c06ea5f..708e7f3 100644 (file)
@@ -17,6 +17,7 @@ $VERSION = 0.01;
 @EXPORT = qw(
              &display_date_format
              &format_date
+             &format_date_in_iso
 );
 
 
@@ -90,4 +91,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;