r86236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86235‎ | r86236 | r86237 >
Date:20:55, 16 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
corrected computation of ISO serialisation
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Time.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Time.php
@@ -776,13 +776,17 @@
777777 *
778778 * Conforming to the 2000 version of ISO8601, year 1 BC(E) is
779779 * represented as "0000", year 2 BC(E) as "-0001" and so on.
780 - * @param $mindefault boolean determining whether values below the precision of our input should be completed with minimal or maximal conceivable values
 780+ *
 781+ * @param $mindefault boolean determining whether values below the
 782+ * precision of our input should be completed with minimal or maximal
 783+ * conceivable values
781784 * @return string
782785 */
783786 public function getISO8601Date( $mindefault = true ) {
784 - $result = ( $this->getYear() < -1 ) ? '-' : '';
 787+ $yearnum = ( $this->getYear() > 0 ) ? $this->getYear() : 1 - $this->getYear();
 788+ $result = ( $this->getYear() > 0 ) ? '' : '-';
785789 $monthnum = $this->getMonth( SMWDITime::CM_GREGORIAN, ( $mindefault ? 1 : 12 ) );
786 - $result .= str_pad( $this->getYear() + 1, 4, "0", STR_PAD_LEFT ) .
 790+ $result .= str_pad( $this->getYear(), 4, "0", STR_PAD_LEFT ) .
787791 '-' . str_pad( $monthnum, 2, "0", STR_PAD_LEFT );
788792 if ( !$mindefault && ( $this->m_dataitem->getPrecision() < SMWDITime::PREC_YMD ) ) {
789793 $maxday = self::getDayNumberForMonth( $monthnum, $this->getYear(), SMWDITime::CM_GREGORIAN );

Follow-up revisions

RevisionCommit summaryAuthorDate
r86334Revert r86236reedy19:00, 18 April 2011

Status & tagging log