r63163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63162‎ | r63163 | r63164 >
Date:09:27, 2 March 2010
Author:mkroetzsch
Status:deferred
Tags:
Comment:
fixed glitches in recent DV_Time updates (also resolves Bug 22560)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php
@@ -111,7 +111,7 @@
112112 protected $m_jd = 0; //numerical time representation similiar to Julian Day; for ancient times, a more compressed number is used (preserving ordering of time points)
113113 protected $m_format = false; // number of parts of the date that were specified
114114 protected $m_outformat = false; // A special code governing printout formats.
115 - protected $m_timeoffset; //contains offset (e.g. timezone)
 115+ protected $m_timeoffset; //contains offset (e.g. timezone)
116116 protected $m_timeannotation; //contains am or pm
117117 protected $m_dayj = false; // Julian day, remains false if unspecified
118118 protected $m_monthj = false; // Julian month, remains false if unspecified
@@ -163,7 +163,7 @@
164164 if ($this->m_caption === false) { // Store the caption now.
165165 $this->m_caption = $value;
166166 }
167 -
 167+
168168 // if the value is a number, and it has at least six places left of decimal, we know
169169 // it's not a year, so treat it as a Julian day, but leave it as the caption and wikivalue.
170170 if (is_numeric($value) && $value >= 100000) {
@@ -173,7 +173,7 @@
174174 $this->m_wikivalue = $value;
175175 return true;
176176 }
177 -
 177+
178178 $this->m_wikivalue = $value;
179179 $filteredvalue = $value; //value without time definition and further abbreviations like PM or BC
180180
@@ -185,14 +185,14 @@
186186 }
187187
188188 //browse string in advance for timezone monikers ("EST", "WET", "MESZ", etc.)
189 - $regexptz = "/A[CEKW]?[DS]T|BST|CXT|[CEW]([DES]|E[DS])T|" .
 189+ $regexptz = "/A[CEKW]?[DS]T|BST|CXT|[CEW]([DES]|E[DS])T|" .
190190 "GMT|H(A[DS]T|[AN][ACEPRTY])|IST|M(DT|E(S)?Z|S[DKT])|N[DFS]T|P[DS]T|UTC/u";
191191 if(preg_match($regexptz, $filteredvalue, $match)) {
192192 // Retrieve the offset and store it as the initial time offset value.
193193 $this->m_timeoffset = $this->m_timeoffset + self::$m_tz[$match[0]]/24;
194194 $regexp = "/(\040|T){0,1}".str_replace("+", "\+", $match[0])."(\040){0,1}/u"; //delete tz moniker and preceding and following chars
195195 $filteredvalue = preg_replace($regexp,'', $filteredvalue); //value without the tz moniker
196 - }
 196+ }
197197
198198 //browse string for special abbreviations referring to year like AD, BC, and OS
199199 $is_yearbc = false;
@@ -303,7 +303,7 @@
304304 $globalvar = 'm_'.$globalvar; // (for searching this file) this is one of: m_year, m_month, m_day
305305 if($prelimModel == 'Jl') {
306306 $globalvar = $globalvar . 'j';
307 - }
 307+ }
308308 if (!$this->$globalvar) $this->$globalvar = intval($array[$i]);
309309 $i++;
310310 }
@@ -335,7 +335,7 @@
336336 if ($this->m_pref == 'OS') {
337337 if(($this->m_monthj < 3) || (($this->m_monthj == 3) && ($this->m_dayj < 25))) {
338338 $this->m_yearj++;
339 - }
 339+ }
340340 }
341341
342342 // Handle BC: the year is negative.
@@ -445,7 +445,7 @@
446446
447447 protected function parseDBkeys($args) {
448448 $this->m_caption = false;
449 - $this->m_pref = array_key_exists(1,$args)?$args[1]:'';
 449+ $this->m_pref = array_key_exists(2,$args)?$args[2]:'';
450450 list($date,$this->m_time) = explode('T',$args[0],2);
451451 $d = explode('/',$date,3);
452452 if (count($d)==3) list($this->m_year,$this->m_month,$this->m_day) = $d;
@@ -488,7 +488,7 @@
489489 }
490490
491491 public function getShortHTMLText($linker = NULL) {
492 - return $this->getShortWikiText($linker); // should be save (based on xsdvalue)
 492+ return $this->getShortWikiText($linker); // should be safe (based on xsdvalue)
493493 }
494494
495495 public function getLongWikiText($linked = NULL) {
@@ -509,19 +509,21 @@
510510 if ($this->m_xsdvalue === false) {
511511 $this->m_xsdvalue = $this->m_year."/".$this->m_month."/".$this->m_day."T".$this->m_time;
512512 }
513 - return array($this->m_xsdvalue, $this->m_pref);
 513+ return array($this->m_xsdvalue, $this->m_jd, $this->m_pref);
514514 }
515515
516 - public function getNumericValue() {
517 - $this->unstub();
518 - return $this->m_jd;
 516+ public function getSignature() {
 517+ return 'tfu';
519518 }
520519
521 - public function getUnit() {
522 - $values = $this->getDBkeys();
523 - return $values[1];
 520+ public function getValueIndex() {
 521+ return 1;
524522 }
525523
 524+ public function getLabelIndex() {
 525+ return 0;
 526+ }
 527+
526528 public function getWikiValue(){
527529 $this->unstub();
528530 return $this->m_wikivalue;
@@ -742,7 +744,7 @@
743745 * (JD) is computed. The JD has the form XXXX.YYYY where XXXX is the number of days having elapsed since
744746 * noon on 1 January 4713 BC and YYYY is the elapsed time of the day as fraction of 1.
745747 * See http://en.wikipedia.org/wiki/Julian_day
746 - * If the year is before -4713, then the computed number XXXX.YYYY has the following form: XXXX is
 748+ * If the year is before -4713, then the computed number XXXX.YYYY has the following form: XXXX is
747749 * the number of years BC and YYYY represents the elapsed days of the year as fraction of 1. This
748750 * enables even large negative dates using 32bit floats.
749751 *
@@ -832,7 +834,7 @@
833835 $this->m_month = 1;
834836 $this->m_year++;
835837 }
836 - }
 838+ }
837839 }
838840
839841 /// Convert Julian Day back to a Julian date.
@@ -848,4 +850,3 @@
849851 $this->m_dayj = ($this->m_format == 3) ? ($b - $d - intval(30.6001 * $e)) : false;
850852 }
851853 }
852 -
\ No newline at end of file

Status & tagging log