Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Time.php |
— | — | @@ -729,7 +729,7 @@ |
730 | 730 | $result .= str_pad( $this->getYear(), 4, "0", STR_PAD_LEFT ) . |
731 | 731 | '-' . str_pad( $monthnum, 2, "0", STR_PAD_LEFT ); |
732 | 732 | if ( !$mindefault && ( $this->m_dataitem->getPrecision() < SMWDITime::PREC_YMD ) ) { |
733 | | - $maxday = self::getDayNumberForMonth( $monthnum, $this->getYear(), SMWDITime::CM_GREGORIAN ); |
| 733 | + $maxday = SMWDITime::getDayNumberForMonth( $monthnum, $this->getYear(), SMWDITime::CM_GREGORIAN ); |
734 | 734 | $result .= '-' . str_pad( $this->getDay( SMWDITime::CM_GREGORIAN, $maxday ), 2, "0", STR_PAD_LEFT ); |
735 | 735 | } else { |
736 | 736 | $result .= '-' . str_pad( $this->getDay(), 2, "0", STR_PAD_LEFT ); |
— | — | @@ -768,10 +768,15 @@ |
769 | 769 | /** |
770 | 770 | * Compute a suitable string to display the given date item. |
771 | 771 | * @note MediaWiki's date functions are not applicable for the range of historic dates we support. |
| 772 | + * |
| 773 | + * @since 1.6 |
| 774 | + * |
| 775 | + * @param SMWDITime $dataitem |
| 776 | + * |
772 | 777 | * @return string |
773 | 778 | * @todo Internationalize the CE and BCE strings. |
774 | 779 | */ |
775 | | - public function getCaptionFromDataitem( $dataitem ) { |
| 780 | + public function getCaptionFromDataitem( SMWDITime $dataitem ) { |
776 | 781 | global $smwgContLang; |
777 | 782 | if ( $dataitem->getYear() > 0 ) { |
778 | 783 | $cestring = ''; |
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Time.php |
— | — | @@ -103,7 +103,7 @@ |
104 | 104 | */ |
105 | 105 | public function __construct( $calendarmodel, $year, $month = false, $day = false, |
106 | 106 | $hour = false, $minute = false, $second = false ) { |
107 | | - if ( ( $calendarmodel != SMWDITime::CM_GREGORIAN ) && ( $calendarmodel != SMWDITime::CM_JULIAN ) ) { |
| 107 | + if ( ( $calendarmodel != self::CM_GREGORIAN ) && ( $calendarmodel != self::CM_JULIAN ) ) { |
108 | 108 | throw new SMWDataItemException( "Unsupported calendar model constant \"$calendarmodel\"." ); |
109 | 109 | } |
110 | 110 | if ( $year == 0 ) { |
— | — | @@ -122,17 +122,17 @@ |
123 | 123 | ( $this->m_month < 1 ) || ( $this->m_month > 12 ) ) { |
124 | 124 | throw new SMWDataItemException( "Part of the date is out of bounds." ); |
125 | 125 | } |
126 | | - if ( $this->m_day > SMWDITime::getDayNumberForMonth( $this->m_month, $this->m_year, $this->m_model ) ) { |
| 126 | + if ( $this->m_day > self::getDayNumberForMonth( $this->m_month, $this->m_year, $this->m_model ) ) { |
127 | 127 | throw new SMWDataItemException( "Month {$this->m_month} in year {$this->m_year} did not have {$this->m_day} days in this calendar model." ); |
128 | 128 | } |
129 | 129 | if ( $month === false ) { |
130 | | - $this->m_precision = SMWDITime::PREC_Y; |
| 130 | + $this->m_precision = self::PREC_Y; |
131 | 131 | } elseif ( $day === false ) { |
132 | | - $this->m_precision = SMWDITime::PREC_YM; |
| 132 | + $this->m_precision = self::PREC_YM; |
133 | 133 | } elseif ( $hour === false ) { |
134 | | - $this->m_precision = SMWDITime::PREC_YMD; |
| 134 | + $this->m_precision = self::PREC_YMD; |
135 | 135 | } else { |
136 | | - $this->m_precision = SMWDITime::PREC_YMDT; |
| 136 | + $this->m_precision = self::PREC_YMDT; |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
— | — | @@ -186,7 +186,7 @@ |
187 | 187 | if ( $calendarmodel == $this->m_model ) { |
188 | 188 | return $this; |
189 | 189 | } else { |
190 | | - return SMWDITime::newFromJD( $this->getJD(), $calendarmodel, $this->m_precision ); |
| 190 | + return self::newFromJD( $this->getJD(), $calendarmodel, $this->m_precision ); |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
— | — | @@ -209,19 +209,19 @@ |
210 | 210 | } |
211 | 211 | |
212 | 212 | public function getJD() { |
213 | | - return SMWDITime::date2JD( $this->m_year, $this->m_month, $this->m_day, $this->m_model ) + |
214 | | - SMWDITime::time2JDoffset( $this->m_hours, $this->m_minutes, $this->m_seconds ); |
| 213 | + return self::date2JD( $this->m_year, $this->m_month, $this->m_day, $this->m_model ) + |
| 214 | + self::time2JDoffset( $this->m_hours, $this->m_minutes, $this->m_seconds ); |
215 | 215 | } |
216 | 216 | |
217 | 217 | public function getSerialization() { |
218 | 218 | $result = strval( $this->m_model ) . '/' . strval( $this->m_year ); |
219 | | - if ( $this->m_precision >= SMWDITime::PREC_YM ) { |
| 219 | + if ( $this->m_precision >= self::PREC_YM ) { |
220 | 220 | $result .= '/' . strval( $this->m_month ); |
221 | 221 | } |
222 | | - if ( $this->m_precision >= SMWDITime::PREC_YMD ) { |
| 222 | + if ( $this->m_precision >= self::PREC_YMD ) { |
223 | 223 | $result .= '/' . strval( $this->m_day ); |
224 | 224 | } |
225 | | - if ( $this->m_precision >= SMWDITime::PREC_YMDT ) { |
| 225 | + if ( $this->m_precision >= self::PREC_YMDT ) { |
226 | 226 | $result .= '/' . strval( $this->m_hours ) . '/' . strval( $this->m_minutes ) . '/' . strval( $this->m_seconds ); |
227 | 227 | } |
228 | 228 | return $result; |
— | — | @@ -264,15 +264,15 @@ |
265 | 265 | * @return SMWDITime object |
266 | 266 | */ |
267 | 267 | public static function newFromJD( $jdvalue, $calendarmodel, $precision ) { |
268 | | - list( $year, $month, $day ) = SMWDITime::JD2Date( $jdvalue, $calendarmodel ); |
269 | | - if ( $precision <= SMWDITime::PREC_YM ) { |
| 268 | + list( $year, $month, $day ) = self::JD2Date( $jdvalue, $calendarmodel ); |
| 269 | + if ( $precision <= self::PREC_YM ) { |
270 | 270 | $day = false; |
271 | | - if ( $precision == SMWDITime::PREC_Y ) { |
| 271 | + if ( $precision == self::PREC_Y ) { |
272 | 272 | $month = false; |
273 | 273 | } |
274 | 274 | } |
275 | | - if ( $precision == SMWDITime::PREC_YMDT ) { |
276 | | - list( $hour, $minute, $second ) = SMWDITime::JD2Time( $jdvalue ); |
| 275 | + if ( $precision == self::PREC_YMDT ) { |
| 276 | + list( $hour, $minute, $second ) = self::JD2Time( $jdvalue ); |
277 | 277 | } else { |
278 | 278 | $hour = $minute = $second = false; |
279 | 279 | } |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | */ |
293 | 293 | static public function date2JD( $year, $month, $day, $calendarmodel ) { |
294 | 294 | $astroyear = ( $year < 1 ) ? ( $year + 1 ) : $year; |
295 | | - if ( $calendarmodel == SMWDITime::CM_GREGORIAN ) { |
| 295 | + if ( $calendarmodel == self::CM_GREGORIAN ) { |
296 | 296 | $a = intval( ( 14 - $month ) / 12 ); |
297 | 297 | $y = $astroyear + 4800 - $a; |
298 | 298 | $m = $month + 12 * $a - 3; |
— | — | @@ -326,7 +326,7 @@ |
327 | 327 | * @return array( yearnumber, monthnumber, daynumber ) |
328 | 328 | */ |
329 | 329 | static public function JD2Date( $jdvalue, $calendarmodel ) { |
330 | | - if ( $calendarmodel == SMWDITime::CM_GREGORIAN ) { |
| 330 | + if ( $calendarmodel == self::CM_GREGORIAN ) { |
331 | 331 | $jdvalue += 2921940; // add the days of 8000 years (this algorithm only works for positive JD) |
332 | 332 | $j = floor( $jdvalue + 0.5 ) + 32044; |
333 | 333 | $g = floor( $j / 146097 ); |
— | — | @@ -384,7 +384,7 @@ |
385 | 385 | */ |
386 | 386 | static public function isLeapYear( $year, $calendarmodel ) { |
387 | 387 | $astroyear = ( $year < 1 ) ? ( $year + 1 ) : $year; |
388 | | - if ( $calendarmodel == SMWDITime::CM_JULIAN ) { |
| 388 | + if ( $calendarmodel == self::CM_JULIAN ) { |
389 | 389 | return ( $astroyear % 4 ) == 0; |
390 | 390 | } else { |
391 | 391 | return ( ( $astroyear % 400 ) == 0 ) || |
— | — | @@ -403,8 +403,8 @@ |
404 | 404 | */ |
405 | 405 | static public function getDayNumberForMonth( $month, $year, $calendarmodel ) { |
406 | 406 | if ( $month !== 2 ) { |
407 | | - return SMWDITime::$m_daysofmonths[$month]; |
408 | | - } elseif ( SMWDITime::isLeapYear( $year, $calendarmodel ) ) { |
| 407 | + return self::$m_daysofmonths[$month]; |
| 408 | + } elseif ( self::isLeapYear( $year, $calendarmodel ) ) { |
409 | 409 | return 29; |
410 | 410 | } else { |
411 | 411 | return 28; |