Hello, It seems that the C4::Dates::format_date function, has a small problem : if the incoming date is 0000-00-00, then the result is : 02/00/0, which is not really a date. I think we should get a '' (nothing) in this case. I tried to understand why this happend, but could not understand. Do you think it's a bug ? -- Paul POULAIN http://www.biblibre.com Expert en Logiciels Libres pour l'info-doc Tel : 04 91 31 45 19
Hi, On Wed, Apr 2, 2008 at 5:30 AM, Paul POULAIN <paul.poulain@free.fr> wrote:
It seems that the C4::Dates::format_date function, has a small problem : if the incoming date is 0000-00-00, then the result is : 02/00/0, which is not really a date. I think we should get a '' (nothing) in this case.
I think format_date should return "" or (better) undef in this case. Right now it does print a warning, but as I recall it currently doesn't return undef in order maintain backwards compatibility with code that used C4::Date. Doing this would require going through a lot of code that uses format_date(), of course. Also, I think we should remove usage of "0000-00-00" to signify a unset date; this should be NULL in database columns and undef in code. Regards, Galen -- Galen Charlton Koha Application Developer LibLime galen.charlton@liblime.com p: 1-888-564-2457 x709
On Wed, Apr 2, 2008 at 9:54 AM, Galen Charlton <galen.charlton@liblime.com> wrote:
Hi,
On Wed, Apr 2, 2008 at 5:30 AM, Paul POULAIN <paul.poulain@free.fr> wrote:
It seems that the C4::Dates::format_date function, has a small problem : if the incoming date is 0000-00-00, then the result is : 02/00/0, which is not really a date. I think we should get a '' (nothing) in this case.
I think format_date should return "" or (better) undef in this case. Right now it does print a warning, but as I recall it currently doesn't return undef in order maintain backwards compatibility with code that used C4::Date.
Doing this would require going through a lot of code that uses format_date(), of course. Also, I think we should remove usage of "0000-00-00" to signify a unset date; this should be NULL in database columns and undef in code. I thought we had already removed all use of 0000-00-00, several months ago. Paul, where are you seeing those kinds of non-date data?
Cheers, -- Joshua Ferraro SUPPORT FOR OPEN-SOURCE SOFTWARE CEO migration, training, maintenance, support LibLime Featuring Koha Open-Source ILS jmf@liblime.com |Full Demos at http://liblime.com/koha |1(888)KohaILS
Hi, On Wed, Apr 2, 2008 at 10:20 AM, Joshua Ferraro <jmf@liblime.com> wrote:
On Wed, Apr 2, 2008 at 9:54 AM, Galen Charlton
Doing this would require going through a lot of code that uses format_date(), of course. Also, I think we should remove usage of "0000-00-00" to signify a unset date; this should be NULL in database columns and undef in code. I thought we had already removed all use of 0000-00-00, several months ago. Paul, where are you seeing those kinds of non-date data?
A quick grep shows that some code, mostly acquisitions and a little circ, still checks for 0000-00-00. Sometimes this is in conjunction with a test for NULL, other times not. Regards, Galen -- Galen Charlton Koha Application Developer LibLime galen.charlton@liblime.com p: 1-888-564-2457 x709
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
participants (4)
-
Galen Charlton -
Joe Atzberger -
Joshua Ferraro -
Paul POULAIN