Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Time.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | protected $m_jdn = ''; //numerical time representation similiar to Julian Day Number |
34 | 34 | protected $m_timeoffset; //contains offset (e.g. timezone) |
35 | 35 | protected $m_timeannotation; //contains am or pm |
36 | | - protected $m_timeisset = true; |
| 36 | + protected $m_timeisset; |
37 | 37 | protected $m_yearbc; //true if year is BC |
38 | 38 | protected $m_months = array("January", "February", "March", "April" , "May" , "June" , "Juli" , "August" , "September" , "October" , "November" , "December"); |
39 | 39 | protected $m_monthsshort = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); |
— | — | @@ -51,15 +51,16 @@ |
52 | 52 | $this->m_timeoffset = 0; |
53 | 53 | $this->m_timepm = false; |
54 | 54 | $this->m_timeisset = false; |
| 55 | + $this->m_timeannotation = false; |
55 | 56 | |
56 | 57 | $this->m_wikivalue = $value; |
57 | 58 | $filteredvalue = $value; //value without time definition and further abbreviations like PM or BC |
58 | 59 | |
59 | 60 | //browse string for special abbreviations referring to time like am, pm |
60 | 61 | if(preg_match("/([Aa]|[Pp])[Mm]/u", $filteredvalue, $match)){ |
61 | | - $this->m_timeannotation = strtolower($match[0]); |
62 | | - $regexp = "/(\040|T){0,1}".str_replace("+", "\+", $match[0])."(\040){0,1}/u"; //delete pm/am, preceding and following chars |
63 | | - $filteredvalue = preg_replace($regexp,'', $filteredvalue); //value without am/pm |
| 62 | + $this->m_timeannotation = strtolower($match[0]); |
| 63 | + $regexp = "/(\040|T){0,1}".str_replace("+", "\+", $match[0])."(\040){0,1}/u"; //delete pm/am, preceding and following chars |
| 64 | + $filteredvalue = preg_replace($regexp,'', $filteredvalue); //value without am/pm |
64 | 65 | } |
65 | 66 | |
66 | 67 | //browse string for special abbreviations referring to year like AD, BC |
— | — | @@ -78,25 +79,24 @@ |
79 | 80 | |
80 | 81 | //timezone handling |
81 | 82 | if(preg_match("/([+\-][0-2]?[0-9](:(30|00))?)/u", $time, $match2)){ //get timezone definition |
82 | | - $offset = $this->normalizeTimeValue($match2[0]); |
83 | | - $sign = 1; |
84 | | - if($offset[0] == '-') $sign = -1; |
85 | | - $offset = substr($offset,1); |
86 | | - list ($offhours, $offminutes, $offseconds) = explode(':',$offset,3); |
87 | | - $offset = $sign * (($offhours / 24) + ($offminutes / (60*24)) + ($offseconds / (3600*24))); |
88 | | - $this->m_timeoffset = $this->m_timeoffset + $offset; |
89 | | - $time = str_replace($match2[0],'',$time); |
| 83 | + $offset = $this->normalizeTimeValue($match2[0]); |
| 84 | + $sign = 1; |
| 85 | + if($offset[0] == '-') $sign = -1; |
| 86 | + $offset = substr($offset,1); |
| 87 | + list ($offhours, $offminutes, $offseconds) = explode(':',$offset,3); |
| 88 | + $offset = $sign * (($offhours / 24) + ($offminutes / (60*24)) + ($offseconds / (3600*24))); |
| 89 | + $this->m_timeoffset = $this->m_timeoffset + $offset; |
| 90 | + $time = str_replace($match2[0],'',$time); |
90 | 91 | } |
91 | 92 | |
92 | 93 | list($hours,$minutes,$seconds) = explode(':',$this->normalizeTimeValue($time),3); |
93 | 94 | |
94 | 95 | //am/pm handling |
95 | | - if($this->m_timeannotation != ''){ |
96 | | - |
97 | | - if(!strcmp($this->m_timeannotation,'am') && $hours == 12) $hours = 0; |
98 | | - if(!strcmp($this->m_timeannotation,'pm') && $hours <= 11){ |
99 | | - $this->m_timeoffset = 0.5; |
100 | | - } |
| 96 | + if($this->m_timeannotation != false){ |
| 97 | + if(!strcmp($this->m_timeannotation,'am') && $hours == 12) $hours = 0; |
| 98 | + if(!strcmp($this->m_timeannotation,'pm') && $hours <= 11){ |
| 99 | + $this->m_timeoffset = $this->m_timeoffset + 0.5; |
| 100 | + } |
101 | 101 | } |
102 | 102 | |
103 | 103 | $this->m_time = $this->normalizeValue($hours).":".$this->normalizeValue($minutes).":".$this->normalizeValue($seconds); |
— | — | @@ -171,7 +171,7 @@ |
172 | 172 | $this->m_year = -$this->m_year; |
173 | 173 | } |
174 | 174 | |
175 | | - //handle offset |
| 175 | + //handle offset |
176 | 176 | if($this->m_timeoffset != 0){ |
177 | 177 | $this->createJDN(); |
178 | 178 | $this->m_jdn = $this->m_jdn + $this->m_timeoffset; |
— | — | @@ -181,6 +181,7 @@ |
182 | 182 | if ($this->m_caption === false) { |
183 | 183 | $this->m_caption = $value; |
184 | 184 | } |
| 185 | + |
185 | 186 | return true; |
186 | 187 | } |
187 | 188 | |
— | — | @@ -278,10 +279,11 @@ |
279 | 280 | |
280 | 281 | public function getExportData() { |
281 | 282 | if ($this->isValid()) { |
282 | | - $lit = new SMWExpLiteral($this->getXSDValue(), $this, 'http://www.w3.org/2001/XMLSchema#dateTime'); |
283 | | - return new SMWExpData($lit); |
| 283 | + $xml = $this->m_year.'-'.$this->normalizeValue($this->m_month).'-'.$this->normalizeValue($this->m_day).'T'.$this->m_time; |
| 284 | + $lit = new SMWExpLiteral($xml, $this, 'http://www.w3.org/2001/XMLSchema#dateTime'); |
| 285 | + return new SMWExpData($lit); |
284 | 286 | } else { |
285 | | - return NULL; |
| 287 | + return NULL; |
286 | 288 | } |
287 | 289 | } |
288 | 290 | |
— | — | @@ -292,9 +294,9 @@ |
293 | 295 | protected function makePrintoutValue() { |
294 | 296 | global $smwgContLang; |
295 | 297 | if ($this->m_printvalue === false) { |
296 | | - $time = ''; |
297 | | - if($this->m_timeisset) $time = $this->m_time; |
298 | | - $this->m_printvalue = $this->m_day." ".$smwgContLang->getMonthLabel($this->m_month)." ".$this->m_year." ".$time; //MediaWiki date function is not applicable any more (no support for BC Dates...) |
| 298 | + if($this->m_timeisset || !(!$this->m_timeisset && $this->m_time=="00:00:00")) $time = $this->m_time; |
| 299 | + if((int)$this->m_day>0) $day = (int)$this->m_day; |
| 300 | + $this->m_printvalue = $day." ".$smwgContLang->getMonthLabel($this->m_month)." ".$this->m_year." ".$time; //MediaWiki date function is not applicable any more (no support for BC Dates...) |
299 | 301 | } |
300 | 302 | } |
301 | 303 | |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Language.php |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | * Return the name of the month with the given number. |
112 | 112 | */ |
113 | 113 | function getMonthLabel($number) { |
114 | | - return $this->m_months[(int)$number]; |
| 114 | + return $this->m_months[(int)($number-1)]; |
115 | 115 | } |
116 | 116 | |
117 | 117 | } |