3 package C4::Circulation::Date;
7 # Copyright 2005 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
30 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
33 shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };;
46 #Get the database handle
47 my $dbh = C4::Context->dbh;
48 return C4::Context->preference('dateformat');
51 sub display_date_format
53 my $dateformat = get_date_format();
55 if ( $dateformat eq "us" )
59 elsif ( $dateformat eq "metric" )
63 elsif ( $dateformat eq "iso" )
69 return "Invalid date format: $dateformat. Please change in system preferences";
84 my $dateformat = get_date_format();
86 if ( $dateformat eq "us" )
88 Date_Init("DateFormat=US");
89 $olddate = ParseDate($olddate);
90 $newdate = UnixDate($olddate,'%m/%d/%Y');
92 elsif ( $dateformat eq "metric" )
94 Date_Init("DateFormat=metric");
95 $olddate = ParseDate($olddate);
96 $newdate = UnixDate($olddate,'%d/%m/%Y');
98 elsif ( $dateformat eq "iso" )
100 Date_Init("DateFormat=iso");
101 $olddate = ParseDate($olddate);
102 $newdate = UnixDate($olddate,'%Y-%m-%d');
106 return "Invalid date format: $dateformat. Please change in system preferences";
110 sub format_date_in_iso
120 my $dateformat = get_date_format();
122 if ( $dateformat eq "us" )
124 Date_Init("DateFormat=US");
125 $olddate = ParseDate($olddate);
127 elsif ( $dateformat eq "metric" )
129 Date_Init("DateFormat=metric");
130 $olddate = ParseDate($olddate);
132 elsif ( $dateformat eq "iso" )
134 Date_Init("DateFormat=iso");
135 $olddate = ParseDate($olddate);
142 $newdate = UnixDate($olddate, '%Y-%m-%d');