Last modified: 2007-05-29 20:08:22 UTC
If you annotate an attribute with Type:Date and provide an invalid date (month >12) it is misinterpreted within ask queries. Reproduce with following steps: 1) Create an attribute with Type:date and use it in some article 2) Use an invalid date with month > 12 (for example: born in:=1970-15-04) 3) Create an ask-query which is asking for the attribute Result: The result table will show a wrong date and a time (for example: 1970-04-06 13:07:00) Expected result: Show an empty filed or an error message "invalid date". The first solution seems to be the more consistent one because if you provide a correct month but an invalid day (for example 2007-04-35) SMW seems to recognise this and the field in the result table is empty. Platform: # MediaWiki: 1.8.2 # PHP: 5.1.6 # MySQL: 4.1.21-community-nt # Extensions: o Cite, adds <ref[ name=id]> and <references/> tags, for citations, by Ævar Arnfjörð Bjarmason o ParserFunctions by Tim Starling o Semantic MediaWiki (version 0.5)
What is displayed in the factbox of the page with the two dates? Hmm, I tried this at http://ontoworld.org/wiki/SMW_unit_test:Test_dates#Invalid_dates and both bad months and bad days result in "[Oops! The date “1970-15-04” was not understood." errors in the factbox and no value is stored in the database. That's the expected behavior. However, ontoworld.org and my local site are both running PHP 5.2. I suspect strtotime() in PHP 5.1.6 handles dates differently. PHP is strongly motivated to do all kinds of odd unexpected date arithmetic. Can you save the following 6 lines somewhere on your site as strtotime.php, load it in a browser, and give me the results? <?php echo "Good date: strtotime('1970-11-04') gives " . strtotime('1970-11-04') . '<br />'; echo "Bad month: strtotime('1970-15-04') gives " . strtotime('1970-15-04') . '<br />'; echo "Bad day: strtotime('2007-04-35') gives " . strtotime('2007-04-35') . '<br />'; phpinfo(); ?> They return Good date: strtotime('1970-11-04') gives 26553600 Bad month: strtotime('1970-15-04') gives Bad day: strtotime('2007-04-35') gives [and then phpinfo] on my site, i.e. the bad dates fail.
Mr. Nitsche confirmed this is an issue with PHP version 5.1.2.