3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
31 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
33 $VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
41 &get_date_format_string_for_DHTMLcalendar
46 #Get the database handle
47 my $dbh = C4::Context->dbh;
48 return C4::Context->preference('dateformat');
51 sub display_date_format {
52 my $dateformat = get_date_format();
54 if ( $dateformat eq "us" ) {
57 elsif ( $dateformat eq "metric" ) {
60 elsif ( $dateformat eq "iso" ) {
65 "Invalid date format: $dateformat. Please change in system preferences";
69 sub get_date_format_string_for_DHTMLcalendar {
70 my $dateformat = get_date_format();
72 if ( $dateformat eq 'us' ) {
75 elsif ( $dateformat eq 'metric' ) {
78 elsif ( $dateformat eq "iso" ) {
82 return 'Invalid date format: '
84 . ' Please change in system preferences';
96 my $dateformat = get_date_format();
98 if ( $dateformat eq "us" ) {
99 Date_Init("DateFormat=US");
100 $olddate = ParseDate($olddate);
101 $newdate = UnixDate( $olddate, '%m/%d/%Y' );
103 elsif ( $dateformat eq "metric" ) {
104 Date_Init("DateFormat=metric");
105 $olddate = ParseDate($olddate);
106 $newdate = UnixDate( $olddate, '%d/%m/%Y' );
108 elsif ( $dateformat eq "iso" ) {
109 Date_Init("DateFormat=iso");
110 $olddate = ParseDate($olddate);
111 $newdate = UnixDate( $olddate, '%Y-%m-%d' );
115 "Invalid date format: $dateformat. Please change in system preferences";
119 sub format_date_in_iso {
127 my $dateformat = get_date_format();
129 if ( $dateformat eq "us" ) {
130 Date_Init("DateFormat=US");
131 $olddate = ParseDate($olddate);
133 elsif ( $dateformat eq "metric" ) {
134 Date_Init("DateFormat=metric");
135 $olddate = ParseDate($olddate);
137 elsif ( $dateformat eq "iso" ) {
138 Date_Init("DateFormat=iso");
139 $olddate = ParseDate($olddate);
145 $newdate = UnixDate( $olddate, '%Y-%m-%d' );