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 ); };
42 get_date_format_string_for_DHTMLcalendar
47 #Get the database handle
48 my $dbh = C4::Context->dbh;
49 return C4::Context->preference('dateformat');
52 sub display_date_format {
53 my $dateformat = get_date_format();
55 if ( $dateformat eq "us" ) {
58 elsif ( $dateformat eq "metric" ) {
61 elsif ( $dateformat eq "iso" ) {
66 "Invalid date format: $dateformat. Please change in system preferences";
70 sub get_date_format_string_for_DHTMLcalendar {
71 my $dateformat = get_date_format();
73 if ( $dateformat eq 'us' ) {
76 elsif ( $dateformat eq 'metric' ) {
79 elsif ( $dateformat eq "iso" ) {
83 return 'Invalid date format: '
85 . ' Please change in system preferences';
97 my $dateformat = get_date_format();
99 if ( $dateformat eq "us" ) {
100 Date_Init("DateFormat=US");
101 $olddate = ParseDate($olddate);
102 $newdate = UnixDate( $olddate, '%m/%d/%Y' );
104 elsif ( $dateformat eq "metric" ) {
105 Date_Init("DateFormat=metric");
106 $olddate = ParseDate($olddate);
107 $newdate = UnixDate( $olddate, '%d/%m/%Y' );
109 elsif ( $dateformat eq "iso" ) {
110 Date_Init("DateFormat=iso");
111 $olddate = ParseDate($olddate);
112 $newdate = UnixDate( $olddate, '%Y-%m-%d' );
116 "Invalid date format: $dateformat. Please change in system preferences";
120 sub format_date_in_iso {
128 my $dateformat = get_date_format();
130 if ( $dateformat eq "us" ) {
131 Date_Init("DateFormat=US");
132 $olddate = ParseDate($olddate);
134 elsif ( $dateformat eq "metric" ) {
135 Date_Init("DateFormat=metric");
136 $olddate = ParseDate($olddate);
138 elsif ( $dateformat eq "iso" ) {
139 Date_Init("DateFormat=iso");
140 $olddate = ParseDate($olddate);
146 $newdate = UnixDate( $olddate, '%Y-%m-%d' );