* fixing "start by" operator
[koha.git] / C4 / Date.pm
index 708e7f3..8c3f72d 100644 (file)
@@ -21,26 +21,17 @@ $VERSION = 0.01;
 );
 
 
-
 sub get_date_format
 {
        #Get the database handle
        my $dbh = C4::Context->dbh;
-
-       #Query the database to get the dateformat
-       my $sth = $dbh->prepare("SELECT value FROM systempreferences WHERE variable='dateformat'");
-
-       $sth->execute();
-
-       my ($dateformat) = $sth->fetchrow;
-       
-       return $dateformat
+       return C4::Context->preference('dateformat');
 }
 
 sub display_date_format
 {
        my $dateformat = get_date_format();
-       
+
        if ( $dateformat eq "us" )
        {
                return "mm/dd/yyyy";
@@ -65,8 +56,13 @@ sub format_date
        my $olddate = shift;
        my $newdate;
 
+       if ( ! $olddate )
+       {
+               return "";
+       }
+
        my $dateformat = get_date_format();
-       
+
        if ( $dateformat eq "us" )
        {
                Date_Init("DateFormat=US");
@@ -95,6 +91,11 @@ sub format_date_in_iso
 {
         my $olddate = shift;
         my $newdate;
+
+        if ( ! $olddate )
+        {
+                return "";
+        }
                 
         my $dateformat = get_date_format();