Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/211738
Change subject: Renamed FULL_PRECISION and TIME_MISSING date precision constants ...................................................................... Renamed FULL_PRECISION and TIME_MISSING date precision constants They are now DATE_AND_TIME and DATE_ONLY, respectively. Also, a field of type 'Date' that has a full date is of precision DATE_ONLY (it used to be FULL_PRECISION), which makes the correct display in the 'calendar' format easier to do. Change-Id: Ib330d17cb22625c7c3116afb077a79ca2e7f8a8f --- M CargoQueryDisplayer.php M parserfunctions/CargoStore.php 2 files changed, 24 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/38/211738/1 diff --git a/CargoQueryDisplayer.php b/CargoQueryDisplayer.php index 1e9272d..18f99e5 100644 --- a/CargoQueryDisplayer.php +++ b/CargoQueryDisplayer.php @@ -124,7 +124,7 @@ // happen, but if it // does - let's just // give up. - $datePrecision = CargoStore::FULL_PRECISION; + $datePrecision = CargoStore::DATE_ONLY; } } $text = self::formatDateFieldValue( $value, $datePrecision, $fieldType ); @@ -188,8 +188,8 @@ return CargoDrilldownUtils::monthToString( date( 'm', $seconds ) ) . ' ' . date( 'o', $seconds ); } else { - // CargoStore::FULL_PRECISION or - // CargoStore::TIME_MISSING + // CargoStore::DATE_AND_TIME or + // CargoStore::DATE_ONLY global $wgAmericanDates; if ( $wgAmericanDates ) { // We use MediaWiki's representation of month @@ -200,7 +200,10 @@ } else { $dateText = date( 'o-m-d', $seconds ); } - if ( $type == 'Date' || $datePrecision == CargoStore::TIME_MISSING ) { + // @TODO - remove the redundant 'Date' check at some + // point. It's here because the "precision" constants + // changed a ittle in version 0.8. + if ( $type == 'Date' || $datePrecision == CargoStore::DATE_ONLY ) { return $dateText; } diff --git a/parserfunctions/CargoStore.php b/parserfunctions/CargoStore.php index 98adcc8..96c4eb7 100644 --- a/parserfunctions/CargoStore.php +++ b/parserfunctions/CargoStore.php @@ -10,8 +10,8 @@ public static $settings = array(); - const FULL_PRECISION = 0; - const TIME_MISSING = 1; + const DATE_AND_TIME = 0; + const DATE_ONLY = 1; const MONTH_ONLY = 2; const YEAR_ONLY = 3; @@ -285,6 +285,7 @@ } } if ( $fieldType == 'Date' || $fieldType == 'Datetime' ) { + $precision = null; if ( $curValue != '' ) { // Special handling if it's just a year. // If it's a number and less than 8 @@ -315,20 +316,26 @@ // of the month. $precision = self::MONTH_ONLY; } else { - $precision = self::FULL_PRECISION; + // We have at least a + // full date. + if ( $fieldType == 'Date' ) { + $precision = self::DATE_ONLY; + } } } $seconds = strtotime( $curValue ); - if ( $precision != self::FULL_PRECISION || $fieldType == 'Date' ) { + if ( $precision == self::DATE_ONLY ) { // Put into YYYY-MM-DD format. $tableFieldValues[$fieldName] = date( 'Y-m-d', $seconds ); - } else { // ( $fieldType == 'Datetime' ) - // Check for "time missing" - // precision. + } else { + // It's a Datetime field, which + // may or may not have a time - + // check for that now. $datePortion = date( 'Y-m-d', $seconds ); $timePortion = date( 'G:i:s', $seconds ); // If it's not right at midnight, // there's definitely a time there. + $precision = self::DATE_AND_TIME; if ( $timePortion !== '0:00:00' ) { $tableFieldValues[$fieldName] = $datePortion . ' ' . $timePortion; } else { @@ -341,14 +348,14 @@ // for either "00" or // "AM" (or "am") in // the original date - // string. If none of - // them is there, + // string. If neither + // one is there, // there's probably no // time. if ( strpos( $cur_value, '00' ) === false && strpos( $cur_value, 'AM' ) === false && strpos( $cur_value, 'am' ) === false ) { - $precision = self::TIME_MISSING; + $precision = self::DATE_ONLY; } // Either way, we just // need the date portion. -- To view, visit https://gerrit.wikimedia.org/r/211738 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib330d17cb22625c7c3116afb077a79ca2e7f8a8f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Cargo Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits