From 333e222461026db671254ca532b2a16c4e07f2f6 Mon Sep 17 00:00:00 2001 From: wolfpac444 Date: Wed, 26 Mar 2003 04:42:56 +0000 Subject: [PATCH] *** empty log message *** --- C4/Date.pm | 36 +++++++++++++++++++++++++++++++++++- moremember.pl | 6 +++--- opac/opac-moredetail.pl | 5 +++-- opac/opac-reserve.pl | 3 ++- opac/opac-user.pl | 11 ++++++----- opac/opac-userdetails.pl | 7 ++++--- opac/opac-userupdate.pl | 8 ++++---- request.pl | 4 +++- 8 files changed, 60 insertions(+), 20 deletions(-) diff --git a/C4/Date.pm b/C4/Date.pm index 5e3a6cfdd6..f6c1e5859b 100644 --- a/C4/Date.pm +++ b/C4/Date.pm @@ -17,10 +17,10 @@ $VERSION = 0.01; @EXPORT = qw( &display_date_format &format_date + &format_date_in_iso ); - sub get_date_format { #Get the database handle @@ -68,16 +68,19 @@ sub format_date if ( $dateformat eq "us" ) { + Date_Init("DateFormat=US"); $olddate = ParseDate($olddate); $newdate = UnixDate($olddate,'%m/%d/%Y'); } elsif ( $dateformat eq "metric" ) { + Date_Init("DateFormat=metric"); $olddate = ParseDate($olddate); $newdate = UnixDate($olddate,'%d/%m/%Y'); } elsif ( $dateformat eq "iso" ) { + Date_Init("DateFormat=iso"); $olddate = ParseDate($olddate); $newdate = UnixDate($olddate,'%Y-%m-%d'); } @@ -87,4 +90,35 @@ sub format_date } } +sub format_date_in_iso +{ + my $olddate = shift; + my $newdate; + + my $dateformat = get_date_format(); + + if ( $dateformat eq "us" ) + { + Date_Init("DateFormat=US"); + $olddate = ParseDate($olddate); + } + elsif ( $dateformat eq "metric" ) + { + Date_Init("DateFormat=metric"); + $olddate = ParseDate($olddate); + } + elsif ( $dateformat eq "iso" ) + { + Date_Init("DateFormat=iso"); + $olddate = ParseDate($olddate); + } + else + { + return "9999-99-99"; + } + + $newdate = UnixDate($olddate, '%Y-%m-%d'); + + return $newdate; +} 1; diff --git a/moremember.pl b/moremember.pl index 41e45c6d63..deacfe7bdb 100755 --- a/moremember.pl +++ b/moremember.pl @@ -128,7 +128,7 @@ for (my$i=0;$i<$numaccts;$i++){ my %row = %$accts->[$i]; if ($amount2 != 0){ my $item="   "; - $row{'date'} = slashifyDate($accts->[$i]{'date'}); + $row{'date'} = format_date($accts->[$i]{'date'}); if ($accts->[$i]{'accounttype'} ne 'Res'){ #get item data @@ -153,7 +153,7 @@ my $today=ParseDate('today'); my @issuedata; for (my $i=0;$i<$count;$i++){ my $datedue=ParseDate($issue->[$i]{'date_due'}); - $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'}); + $issue->[$i]{'date_due'} = format_date($issue->[$i]{'date_due'}); my %row = %{$issue->[$i]}; if ($datedue < $today){ $row{'red'}=1; #print ""; @@ -190,7 +190,7 @@ my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2 # my @reservedata; for (my $i=0;$i<$rescount;$i++){ - $reserves->[$i]{'reservedate2'} = slashifyDate($reserves->[$i]{'reservedate'}); + $reserves->[$i]{'reservedate2'} = format_date($reserves->[$i]{'reservedate'}); my $restitle; my %row = %$reserves->[$i]; if ($reserves->[$i]{'constrainttype'} eq 'o'){ diff --git a/opac/opac-moredetail.pl b/opac/opac-moredetail.pl index 59b626fac8..214d13e961 100755 --- a/opac/opac-moredetail.pl +++ b/opac/opac-moredetail.pl @@ -10,6 +10,7 @@ use C4::Koha; use C4::Output; use C4::Acquisitions; use C4::Biblio; +use C4::Date; use HTML::Template; use CGI; @@ -139,8 +140,8 @@ my $mon=substr($items[$i]->{'timestamp0'},4,2); my $day=substr($items[$i]->{'timestamp0'},6,2); $items[$i]->{'timestamp0'}="$day/$mon/$year"; -$items[$i]->{'dateaccessioned'} = slashifyDate($items[$i]->{'dateaccessioned'}); -$items[$i]->{'datelastseen'} = slashifyDate($items[$i]->{'datelastseen'}); +$items[$i]->{'dateaccessioned'} = format_date($items[$i]->{'dateaccessioned'}); +$items[$i]->{'datelastseen'} = format_date($items[$i]->{'datelastseen'}); print < diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index ff54f0571e..081416a088 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -12,6 +12,7 @@ use C4::Circulation::Circ2; use C4::Reserves2; use C4::Interface::CGI::Output; use HTML::Template; +use C4::Date; my $MAXIMUM_NUMBER_OF_RESERVES = 5; @@ -122,7 +123,7 @@ my %types; my %itemtypes; my @duedates; foreach my $itm (@items) { - push @duedates, {date_due => slashifyDate($itm->{'date_due'})} if defined $itm->{'date_due'}; + push @duedates, {date_due => format_date($itm->{'date_due'})} if defined $itm->{'date_due'}; $itm->{$itm->{'publictype'}} = 1; # FIXME CalcReserveFee is supposed to be internal-use-only my $fee = CalcReserveFee(undef, $borrowernumber, $itm->{'biblionumber'},'a',($itm->{'biblioitemnumber'})); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 0ff4c48925..faf7b65e66 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -11,6 +11,7 @@ use C4::Reserves2; use C4::Search; use C4::Interface::CGI::Output; use HTML::Template; +use C4::Date; my $query = new CGI; my ($template, $borrowernumber, $cookie) @@ -25,9 +26,9 @@ my ($template, $borrowernumber, $cookie) # get borrower information .... my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); -$borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'}); -$borr->{'expiry'} = slashifyDate($borr->{'expiry'}); -$borr->{'dateofbirth'} = slashifyDate($borr->{'dateofbirth'}); +$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'}); +$borr->{'expiry'} = format_date($borr->{'expiry'}); +$borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'}); $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'}); if ($borr->{'amountoutstanding'} > 5) { @@ -58,7 +59,7 @@ my @overdues; my @issuedat; foreach my $key (keys %$issues) { my $issue = $issues->{$key}; - $issue->{'date_due'} = slashifyDate($issue->{'date_due'}); + $issue->{'date_due'} = format_date($issue->{'date_due'}); # check for reserves my ($restype, $res) = CheckReserves($issue->{'itemnumber'}); @@ -109,7 +110,7 @@ my $branches = getbranches(); # now the reserved items.... my ($rcount, $reserves) = FindReserves(undef, $borrowernumber); foreach my $res (@$reserves) { - $res->{'reservedate'} = slashifyDate($res->{'reservedate'}); + $res->{'reservedate'} = format_date($res->{'reservedate'}); my $publictype = $res->{'publictype'}; $res->{$publictype} = 1; $res->{'waiting'} = 1 if $res->{'found'} eq 'W'; diff --git a/opac/opac-userdetails.pl b/opac/opac-userdetails.pl index 5f98d19246..b0bfe8472d 100755 --- a/opac/opac-userdetails.pl +++ b/opac/opac-userdetails.pl @@ -9,6 +9,7 @@ use C4::Circulation::Circ2; use C4::Search; use HTML::Template; use C4::Interface::CGI::Output; +use C4::Date; my $query = new CGI; my ($template, $borrowernumber, $cookie) @@ -23,9 +24,9 @@ my ($template, $borrowernumber, $cookie) # get borrower information .... my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); -$borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'}); -$borr->{'expiry'} = slashifyDate($borr->{'expiry'}); -$borr->{'dateofbirth'} = slashifyDate($borr->{'dateofbirth'}); +$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'}); +$borr->{'expiry'} = format_date($borr->{'expiry'}); +$borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'}); $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'}); diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl index c810b2a34d..a34c638781 100755 --- a/opac/opac-userupdate.pl +++ b/opac/opac-userupdate.pl @@ -10,7 +10,7 @@ use C4::Koha; use C4::Circulation::Circ2; use C4::Interface::CGI::Output; use HTML::Template; - +use C4::Date; my $query = new CGI; @@ -78,9 +78,9 @@ EOF } -$borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'}); -$borr->{'expiry'} = slashifyDate($borr->{'expiry'}); -$borr->{'dateofbirth'} = slashifyDate($borr->{'dateofbirth'}); +$borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'}); +$borr->{'expiry'} = format_date($borr->{'expiry'}); +$borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'}); $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'}); diff --git a/request.pl b/request.pl index 3653efe891..bcf7be71c7 100755 --- a/request.pl +++ b/request.pl @@ -34,6 +34,8 @@ use C4::Circulation::Circ2; use HTML::Template; use C4::Catalogue; use CGI; +use C4::Date; + my $input = new CGI; # get biblio information.... @@ -154,7 +156,7 @@ foreach my $res (sort {$a->{'found'} cmp $b->{'found'}} @$reserves){ $reserve{'wbrcode'} = $res->{'branchcode'}; $reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'}; } - $reserve{'date'} = slashifyDate($res->{'reservedate'}); + $reserve{'date'} = format_date($res->{'reservedate'}); $reserve{'borrowernumber'}=$res->{'borrowernumber'}; $reserve{'biblionumber'}=$res->{'biblionumber'}; $reserve{'bornum'}=$res->{'borrowernumber'}; -- 2.39.5