[Koha-cvs] koha bull/statecollection.pl bull/subscription-... [rel_2_2]
Henri-Damien LAURENT
laurenthdl at alinto.com
Tue Dec 5 15:57:55 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_2_2
Changes by: Henri-Damien LAURENT <hdl> 06/12/05 14:57:55
Modified files:
bull : statecollection.pl subscription-add.pl
subscription-detail.pl
C4 : Date.pm Members.pm
Log message:
Using Date::Calc
And modifying dates so that PARTIAL dates (Only Year/Month or only Year) are saved into database.
Before, it resulted into null dates.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/bull/statecollection.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.3.2.22&r2=1.3.2.23
http://cvs.savannah.gnu.org/viewcvs/koha/bull/subscription-add.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.5.2.7&r2=1.5.2.8
http://cvs.savannah.gnu.org/viewcvs/koha/bull/subscription-detail.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.5.2.6&r2=1.5.2.7
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Date.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.13&r2=1.13.4.1
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Members.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.6.2.6&r2=1.6.2.7
Patches:
Index: bull/statecollection.pl
===================================================================
RCS file: /sources/koha/koha/bull/Attic/statecollection.pl,v
retrieving revision 1.3.2.22
retrieving revision 1.3.2.23
diff -u -b -r1.3.2.22 -r1.3.2.23
--- bull/statecollection.pl 4 Dec 2006 05:27:27 -0000 1.3.2.22
+++ bull/statecollection.pl 5 Dec 2006 14:57:55 -0000 1.3.2.23
@@ -19,6 +19,8 @@
my $auser = $query->param('user');
my $histstartdate = format_date_in_iso($query->param('histstartdate'));
my $enddate = format_date_in_iso($query->param('enddate'));
+warn "param :".$query->param('histstartdate')."format_date_in_iso".$histstartdate;
+warn "param :".$query->param('enddate')."format_date_in_iso".$enddate;
my $recievedlist = $query->param('recievedlist');
my $missinglist = $query->param('missinglist');
my $opacnote = $query->param('opacnote');
@@ -63,7 +65,7 @@
my ($oldstatus) = $sth->fetchrow;
if ($serialids[$i]) {
- my $planneddate = ($planneddates[$i]?format_date_in_iso($planneddates[$i]):format_date_in_iso("today"));
+ my $planneddate = ($planneddates[$i]?format_date_in_iso($planneddates[$i]):sprintf("%04d-%02d-%02d",Date::Calc::Today));
if(C4::Context->preference("RoutingSerials")){
old_serialchangestatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),$status[$i],$notes[$i]) unless ($hassubscriptionexpired && $oldstatus == 1);
} else {
@@ -88,7 +90,7 @@
}
} else {
# add a special issue
- my $planneddate = ($planneddates[$i]?format_date_in_iso($planneddates[$i]):format_date_in_iso("today"));
+ my $planneddate = ($planneddates[$i]?format_date_in_iso($planneddates[$i]):sprintf("%04d-%02d-%02d",Date::Calc::Today));
if ($serialseqs[$i]) {
newissue($serialseqs[$i],$subscriptionid,$subscription->{bibnum},$status[$i],format_date_in_iso($publisheddates[$i]),$planneddate);
my $rq=$dbh->prepare("SELECT LAST_INSERT_ID()");
Index: bull/subscription-add.pl
===================================================================
RCS file: /sources/koha/koha/bull/Attic/subscription-add.pl,v
retrieving revision 1.5.2.7
retrieving revision 1.5.2.8
diff -u -b -r1.5.2.7 -r1.5.2.8
--- bull/subscription-add.pl 27 Nov 2006 04:39:35 -0000 1.5.2.7
+++ bull/subscription-add.pl 5 Dec 2006 14:57:55 -0000 1.5.2.8
@@ -12,7 +12,7 @@
use C4::Context;
use HTML::Template;
use C4::Bull;
-use Date::Manip;
+use Date::Calc;
my $query = new CGI;
my $op = $query->param('op');
@@ -38,15 +38,15 @@
my $weekarrayjs='';
my $count = 0;
-my ($year, $month, $day) = UnixDate("today", "%Y", "%m", "%d");
-my $firstday = Date_DayOfYear($month,$day,$year);
-my $wkno = Date_WeekOfYear($month,$day,$year,1); # week starting monday
+my ($year, $month, $day) = Date::Calc::Today;
+my $firstday = Day_of_Year($month,$day,$year);
+my $wkno = Week_of_Year($month,$day,$year,1); # week starting monday
my $weekno = $wkno;
for(my $i=$firstday;$i<($firstday+365);$i=$i+7){
$count = $i;
if($wkno > 52){$year++; $wkno=1;}
if($count>365){$count=$i-365;}
- my ($y,$m,$d) = Date_NthDayOfYear($year,$count);
+ my ($y,$m,$d) = Add_Delta_Days($year,1,1, $count - 1);
my $output = "$y-$m-$d";
$weekarrayjs .= "'Wk $wkno: ".format_date($output)."',";
$wkno++;
Index: bull/subscription-detail.pl
===================================================================
RCS file: /sources/koha/koha/bull/Attic/subscription-detail.pl,v
retrieving revision 1.5.2.6
retrieving revision 1.5.2.7
diff -u -b -r1.5.2.6 -r1.5.2.7
--- bull/subscription-detail.pl 27 Nov 2006 05:33:23 -0000 1.5.2.6
+++ bull/subscription-detail.pl 5 Dec 2006 14:57:55 -0000 1.5.2.7
@@ -10,7 +10,7 @@
use C4::Interface::CGI::Output;
use C4::Context;
use HTML::Template;
-use Date::Manip;
+use Date::Calc;
my $query = new CGI;
my $op = $query->param('op');
@@ -126,15 +126,16 @@
my $weekarrayjs='';
my $count = 0;
-my ($year, $month, $day) = UnixDate("today", "%Y", "%m", "%d");
-my $firstday = Date_DayOfYear($month,$day,$year);
-my $wkno = Date_WeekOfYear($month,$day,$year,1); # week starting monday
+my ($year, $month, $day) = Date::Calc::Today;
+my $firstday = Day_of_Year($month,$day,$year);
+my $wkno = Week_of_Year($month,$day,$year,1); # week starting monday
my $weekno = $wkno;
for(my $i=$firstday;$i<($firstday+365);$i=$i+7){
$count = $i;
if($wkno > 52){$year++; $wkno=1;}
if($count>365){$count=$i-365;}
- my ($y,$m,$d) = Date_NthDayOfYear($year,$count);
+# my ($y,$m,$d) = Date_NthDayOfYear($year,$count);
+ my ($y,$m,$d) = Add_Delta_Days($year,1,1, $count - 1);
my $output = "$y-$m-$d";
$weekarrayjs .= "'Wk $wkno: ".format_date($output)."',";
$wkno++;
Index: C4/Date.pm
===================================================================
RCS file: /sources/koha/koha/C4/Date.pm,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -u -b -r1.13 -r1.13.4.1
--- C4/Date.pm 8 Apr 2003 11:30:55 -0000 1.13
+++ C4/Date.pm 5 Dec 2006 14:57:55 -0000 1.13.4.1
@@ -4,7 +4,7 @@
use strict;
use C4::Context;
-use Date::Manip;
+use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date check_date);
require Exporter;
@@ -61,30 +61,34 @@
return "";
}
+ warn $olddate;
+# $olddate=~s#/|\.|-##g;
+ my ($year,$month,$day)=Parse_Date($olddate);
+ ($year,$month,$day)=split /-|\/|\.|:/,$olddate unless ($year && $month);
+# warn "$olddate annee $year mois $month jour $day";
+ if ($year>0 && $month>0){
my $dateformat = get_date_format();
-
+ $dateformat="metric" if (index(":",$olddate)>0);
if ( $dateformat eq "us" )
{
- Date_Init("DateFormat=US");
- $olddate = ParseDate($olddate);
- $newdate = UnixDate($olddate,'%m/%d/%Y');
+ $newdate = sprintf("%02d/%02d/%04d",$month,$day,$year);
}
elsif ( $dateformat eq "metric" )
{
- Date_Init("DateFormat=metric");
- $olddate = ParseDate($olddate);
- $newdate = UnixDate($olddate,'%d/%m/%Y');
+ $newdate = sprintf("%02d/%02d/%04d",$day,$month,$year);
}
elsif ( $dateformat eq "iso" )
{
- Date_Init("DateFormat=iso");
- $olddate = ParseDate($olddate);
- $newdate = UnixDate($olddate,'%Y-%m-%d');
+ # Date_Init("DateFormat=iso");
+ $newdate = sprintf("%04d-%02d-%02d",$year,$month,$day);
}
else
{
return "Invalid date format: $dateformat. Please change in system preferences";
}
+ warn "newdate :$newdate";
+ }
+ return $newdate;
}
sub format_date_in_iso
@@ -98,28 +102,44 @@
}
my $dateformat = get_date_format();
-
+ my ($year,$month,$day);
+ my @date;
+ my $tmpolddate=$olddate;
+ $tmpolddate=~s#/|\.|-|\\##g;
+ $dateformat="metric" if (index(":",$olddate)>0);
if ( $dateformat eq "us" )
{
- Date_Init("DateFormat=US");
- $olddate = ParseDate($olddate);
+ ($month,$day,$year)=split /-|\/|\.|:/,$olddate unless ($year && $month);
+ if ($month>0 && $day >0){
+ @date = Decode_Date_US($tmpolddate);
+ } else {
+ @date=($year, $month,$day)
+ }
}
elsif ( $dateformat eq "metric" )
{
- Date_Init("DateFormat=metric");
- $olddate = ParseDate($olddate);
+ ($day,$month,$year)=split /-|\/|\.|:/,$olddate unless ($year && $month);
+ if ($month>0 && $day >0){
+ @date = Decode_Date_EU($tmpolddate);
+ } else {
+ @date=($year, $month,$day)
+ }
}
elsif ( $dateformat eq "iso" )
{
- Date_Init("DateFormat=iso");
- $olddate = ParseDate($olddate);
+ ($year,$month,$day)=split /-|\/|\.|:/,$olddate unless ($year && $month);
+ if ($month>0 && $day >0){
+ @date=($year, $month,$day) if (check_date($year,$month,$day));
+ } else {
+ @date=($year, $month,$day)
+ }
}
else
{
return "9999-99-99";
}
- $newdate = UnixDate($olddate, '%Y-%m-%d');
+ $newdate = sprintf("%04d-%02d-%02d",$date[0],$date[1],$date[2]);
return $newdate;
}
Index: C4/Members.pm
===================================================================
RCS file: /sources/koha/koha/C4/Members.pm,v
retrieving revision 1.6.2.6
retrieving revision 1.6.2.7
diff -u -b -r1.6.2.6 -r1.6.2.7
--- C4/Members.pm 3 Apr 2006 23:43:20 -0000 1.6.2.6
+++ C4/Members.pm 5 Dec 2006 14:57:55 -0000 1.6.2.7
@@ -22,8 +22,8 @@
use strict;
require Exporter;
use C4::Context;
-use Date::Manip;
use C4::Date;
+use Date::Calc qw(Add_Delta_YM);
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
@@ -129,17 +129,24 @@
my (%data) = @_;
my $dbh = C4::Context->dbh;
$data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'});
- $data{'joining'} = &ParseDate("today") unless $data{'joining'};
+ if ($data{'joining'}){
$data{'joining'}=format_date_in_iso($data{'joining'});
+ } else {
+ $data{'joining'} = sprintf("%04d-%02d-%02d",Date::Calc::Today);
+ }
# if expirydate is not set, calculate it from borrower category subscription duration
- unless ($data{'expiry'}) {
+ if ($data{'expiry'}) {
+ $data{'expiry'}=format_date_in_iso($data{'expiry'});
+ } else {
my $sth = $dbh->prepare("select enrolmentperiod from categories where categorycode=?");
$sth->execute($data{'categorycode'});
my ($enrolmentperiod) = $sth->fetchrow;
- $enrolmentperiod = 12 unless ($enrolmentperiod);
- $data{'expiry'} = &DateCalc($data{'joining'},"$enrolmentperiod years");
+ $enrolmentperiod = 1 unless ($enrolmentperiod);
+ my ($y,$m,$d)=split /-/,$data{'joining'};
+ foreach(Add_Delta_YM($y,$m,$d,$enrolmentperiod,0)){warn "$_\t";}
+ warn "".$enrolmentperiod;
+ $data{'expiry'} = sprintf("%04d-%02d-%02d",Add_Delta_YM($y,$m,$d,$enrolmentperiod,0));
}
- $data{'expiry'}=format_date_in_iso($data{'expiry'});
# $data{'borrowernumber'}=NewBorrowerNumber();
my $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
firstname,altnotes,dateofbirth,contactname,emailaddress,textmessaging,dateenrolled,streetcity,
More information about the Koha-cvs
mailing list