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
29 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
31 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
32 shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
45 C4::Circulation::Date provides routines for format dates to display in human readable forms.
53 =head2 get_date_format
55 $dateformat = get_date_format();
57 Takes no input, and returns the format that the library prefers dates displayed in
64 # Get the database handle
65 my $dbh = C4::Context->dbh;
66 return C4::Context->preference('dateformat');
69 =head2 display_date_format
71 $displaydateformat = display_date_format();
73 Takes no input, and returns a string showing the format the library likes dates displayed in
78 sub display_date_format {
79 my $dateformat = get_date_format();
81 if ( $dateformat eq "us" ) {
84 elsif ( $dateformat eq "metric" ) {
87 elsif ( $dateformat eq "iso" ) {
92 "Invalid date format: $dateformat. Please change in system preferences";
98 $formatteddate = format_date($date);
100 Takes a date, from mysql and returns it in the format specified by the library
101 This is less flexible than C4::Date::format_date, which can handle dates of many formats
102 if you need that flexibility use C4::Date, if you are just using it to format the output from mysql as
103 in circulation.pl use this one, it is much faster.
115 my $dateformat = get_date_format();
117 if ( $dateformat eq "us" ) {
118 my @datearray=split('-',$olddate);
119 $newdate = "$datearray[1]/$datearray[2]/$datearray[0]";
121 elsif ( $dateformat eq "metric" ) {
122 my @datearray=split('-',$olddate);
123 $newdate = "$datearray[2]/$datearray[1]/$datearray[0]";
125 elsif ( $dateformat eq "iso" ) {
130 "Invalid date format: $dateformat. Please change in system preferences";