[Koha] Date problem - tracing from HTML through perl files
Robert Lyon
bob at katipo.co.nz
Thu May 17 09:37:30 NZST 2007
Hi Greg,
I took a look at this and found here ->
http://search.cpan.org/dist/Date-Calc/Calc.pod
and found this:
|if (($year,$month,$day) = Parse_Date($string))|
This function is useful for parsing dates as returned by the UNIX
"|date|" command or as found in the headers of e-mail (in order to
determine the date at which some e-mail has been sent or received, for
instance).
So I tried this:
!/usr/bin/perl -w
use Date::Manip;
use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date
check_date);
$date = ParseDate('today');
print $date."\n";
$date2 = 'Thu May 17 09:35:43 NZST 2007';
print $date2."\n";
my ($year,$month,$day)=Parse_Date($date);
print "Year: $year\n";
print "Month: $month\n";
print "Day: $day\n";
my ($year2,$month2,$day2)=Parse_Date($date2);
print "Year: $year2\n";
print "Month: $month2\n";
print "Day: $day2\n";
which gave me this:
2007051709:38:42
Thu May 17 09:35:43 NZST 2007
Use of uninitialized value in concatenation (.) or string at test.pl
line 13.
Year:
Use of uninitialized value in concatenation (.) or string at test.pl
line 14.
Month:
Use of uninitialized value in concatenation (.) or string at test.pl
line 15.
Day:
Year: 2007
Month: 5
Day: 17
So it looks as if the date being passed to the Parse_Date() may be in
the wrong format
Bob
Greg Vickers wrote:
> Hi all,
>
> I'm trying to find where Koha 2.2.9 is failing when we create a new
> user. I'm going to trace it through from the HTML page right through the
> perl files that get called. I'll document my progress in this email and
> I'll find the problem (eventually) or someone will be able to give me a
> helping hand.
>
> OK, logging on to Koha and going Members -> Add Members
> (http://<sanitized>/cgi-bin/koha/members/memberentry.pl?actionType=Add)
>
> Entering:
> Member#: dmn01
> Given Names: Delete Me
> Surname: Now
> Postal Address: somewhere
> Town: Else
>
> Leaving all other fields blank and clicking the 'Save' button gives:
> Card number: dmn01
> ...
> Joined: ,
> Expires:
>
> Joined and Expires dates are not automatically calculated. Librarians
> can manually enter these fields but it's a pain since the system used to
> automatically calculate them.
>
> Even if I manually enter a date into Joined when creating a new member,
> the Expires field is still blank after the user is created.
>
> Tracing through memberentry.pl, so long as $nok remains undefined then
> we get to here:
> my $query="Select * from borrowers where borrowernumber=?";
> my $sth=$dbh->prepare($query);
> $sth->execute($data{'borrowernumber'});
> if (my $data2=$sth->fetchrow_hashref){
> &modmember(%data);
> }else{
> $borrowernumber = &newmember(%data);
> }
>
> So I assume that $data2 is undefined when creating a new member and we
> call newmember with the array %data. Which is newmember.pl in the same
> directory as memberentry.pl ... bla bla bla ...
>
> Following newmember.pl we get to this:
> if ($data{'joining'} eq ''){
> $data{'joining'}=ParseDate('today');
> $data{'joining'}=format_date($data{'joining'});
> }
>
> Running this line at the command prompt:
> perl -MDate::Manip -e 'print(ParseDate('today'));'
> spits out this string: 2007051622:19:35
>
> So ParseDate appears to return a string, but I don't know if it is in
> the correct format.
>
> BTW our Koha system preference for date is set to ISO.
>
> Digging through the Koha module C4::Date (intranet/modules/C4/Date.pm)
> to see how format_date works, we get this:
> my ($year,$month,$day)=Parse_Date($olddate);
>
> Now Parse_Date in C4::Date comes from:
> use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date
> check_date);
>
> Reading the Perl CPAN page about Parse_Date I wrote this code:
>
> ~ cat runme.pl
> #!/usr/bin/perl -w
>
> use Date::Manip;
> use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date
> check_date);
>
> $date = ParseDate('today');
> print $date."\n";
>
> my ($year,$month,$day)=Parse_Date($date);
> print "Year: $year\n";
> print "Month: $month\n";
> print "Day: $day\n";
>
> And surprise, surprise, we get the following output:
> ./runme.pl
> 2007051622:29:53
> Use of uninitialized value in concatenation (.) or string at ./runme.pl
> line 10.
> Year:
> Use of uninitialized value in concatenation (.) or string at ./runme.pl
> line 11.
> Month:
> Use of uninitialized value in concatenation (.) or string at ./runme.pl
> line 12.
> Day:
>
> Bastard. $year, $month and $day are all undefined. So Parse_Date is
> failing to parse 2007051622:29:53 correctly. What the feck do I do to
> correct it? Any suggestions about the best course of attack? I could
> just go in with a crowbar but I'd like some suggestions first :)
>
> Anyway, I'm going to bed now :)
>
> Thanks,
> Greg
>
> _______________________________________________
> Koha mailing list
> Koha at lists.katipo.co.nz
> http://lists.katipo.co.nz/mailman/listinfo/koha
--
Robert Lyon
Katipo Communications
More information about the Koha
mailing list