1 package C4::Circulation::Date;
3 # Copyright 2005 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
27 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
29 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
30 shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
43 C4::Circulation::Date provides routines for format dates to display in human readable forms.
51 =head2 get_date_format
53 $dateformat = get_date_format();
55 Takes no input, and returns the format that the library prefers dates displayed in
62 # Get the database handle
63 my $dbh = C4::Context->dbh;
64 return C4::Context->preference('dateformat');
67 =head2 display_date_format
69 $displaydateformat = display_date_format();
71 Takes no input, and returns a string showing the format the library likes dates displayed in
76 sub display_date_format {
77 my $dateformat = get_date_format();
79 if ( $dateformat eq "us" ) {
82 elsif ( $dateformat eq "metric" ) {
85 elsif ( $dateformat eq "iso" ) {
90 "Invalid date format: $dateformat. Please change in system preferences";
96 $formatteddate = format_date($date);
98 Takes a date, from mysql and returns it in the format specified by the library
99 This is less flexible than C4::Date::format_date, which can handle dates of many formats
100 if you need that flexibility use C4::Date, if you are just using it to format the output from mysql as
101 in circulation.pl use this one, it is much faster.
113 my $dateformat = get_date_format();
115 if ( $dateformat eq "us" ) {
116 my @datearray=split('-',$olddate);
117 $newdate = "$datearray[1]/$datearray[2]/$datearray[0]";
119 elsif ( $dateformat eq "metric" ) {
120 my @datearray=split('-',$olddate);
121 $newdate = "$datearray[2]/$datearray[1]/$datearray[0]";
123 elsif ( $dateformat eq "iso" ) {
128 "Invalid date format: $dateformat. Please change in system preferences";