[Koha-devel] question/problem with date

Joe Atzberger ohiocore at gmail.com
Wed Apr 2 18:09:57 CEST 2008


Paul --

if the incoming date is 0000-00-00, then the result is : 02/00/0, which is
> not really a date.
>

0000-00-00 is not really a date either, and certainly not ISO.   Currently
the module notices, warns, but stops short of returning undef.   (My earlier
versions were more strict about input.)  The 00 values are passed through to
POSIX::strftime.

At the risk of getting too technical, here's the processing.

RegExp matches based on incoming format (ISO):
qr/^(\d{4})$delim(\d{2})$delim(\d{2})(?:\s{1}(\d{2})\'%Y-%m-%d':?(\d{2})\:?(\d{2}))?/;

Don't worry about the last part: it is there in case we decide to support
times.

Then the array passed to POSIX::strftime '%Y-%m-%d' is:
(0,0,0,$3, $2 - 1, $1 - 1900)

That is, for 0000-00-00:
(0,0,0, 0, -1, -1900)


So the output you see is in fact the output of strftime based on your
input.  You can confirm with the following one-liner:

perl -e 'use POSIX qw(strftime); print
POSIX::strftime("%Y-%m-%d",0,0,0,0,-1,-1900), "\n";'

--joe atzberger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-devel/attachments/20080402/537736e7/attachment-0002.htm>


More information about the Koha-devel mailing list