r58375 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58374‎ | r58375 | r58376 >
Date:20:19, 30 October 2009
Author:yaron
Status:deferred
Tags:
Comment:
Changed date input to use SMWTimeValue(), instead of strtotime(), for parsing dates
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormInputs.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormInputs.inc
@@ -463,10 +463,14 @@
464464 $month = $date['month'];
465465 $day = $date['day'];
466466 } else {
467 - $actual_date = strtotime($date);
468 - $year = date("Y", $actual_date);
469 - $month = date("n", $actual_date);
470 - $day = date("j", $actual_date);
 467+ $actual_date = new SMWTimeValue('_dat');
 468+ $actual_date->setUserValue($date);
 469+ $year = $actual_date->getYear();
 470+ // TODO - the code to convert from negative to BC notation should
 471+ // be in SMW itself
 472+ if ($year < 0) {$year = ($year * -1 + 1) . " BC";}
 473+ $month = $actual_date->getMonth();
 474+ $day = $actual_date->getDay();
471475 }
472476 } else {
473477 $cur_date = getdate();
@@ -505,6 +509,8 @@
506510 }
507511 if (isset($datetime['timezone'])) $timezone = $datetime['timezone'];
508512 } else {
 513+ // TODO - this should change to use SMW's own date-handling class,
 514+ // just like dateEntryHTML() does
509515 $actual_date = strtotime($datetime);
510516 if ($sfg24HourTime) {
511517 $hour = date("G", $actual_date);

Status & tagging log