}
/**
- * Get a namespace key by value, case insensetive.
+ * Get a namespace key by value, case insensitive.
+ * Only matches namespace names for the current language, not the
+ * canonical ones defined in Namespace.php.
+ *
+ * @param string $text
+ * @return mixed An integer if $text is a valid value otherwise false
+ */
+ function getLocalNsIndex( $text ) {
+ $this->load();
+ $lctext = $this->lc($text);
+ return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
+ }
+
+ /**
+ * Get a namespace key by value, case insensitive. Canonical namespace
+ * names override custom ones defined for the current language.
*
* @param string $text
* @return mixed An integer if $text is a valid value otherwise false
function getNsIndex( $text ) {
$this->load();
$lctext = $this->lc($text);
+ if( ( $ns = Namespace::getCanonicalIndex( $lctext ) ) !== null ) return $ns;
return isset( $this->mNamespaceIds[$lctext] ) ? $this->mNamespaceIds[$lctext] : false;
}
if ( $tz === '' ) {
# Global offset in minutes.
if( isset($wgLocalTZoffset) ) {
- $hrDiff = $wgLocalTZoffset % 60;
- $minDiff = $wgLocalTZoffset - ($hrDiff * 60);
+ if( $wgLocalTZoffset >= 0 ) {
+ $hrDiff = floor($wgLocalTZoffset / 60);
+ } else {
+ $hrDiff = ceil($wgLocalTZoffset / 60);
+ }
+ $minDiff = $wgLocalTZoffset % 60;
}
} elseif ( strpos( $tz, ':' ) !== false ) {
$tzArray = explode( ':', $tz );
function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
$this->load();
- ## Account for non-integer timestamps
- if (substr($ts,4,1) === '-') {
- $ts = preg_replace('/\D/', '', $ts);
- }
+ $ts = wfTimestamp( TS_MW, $ts );
if ( $adj ) {
$ts = $this->userAdjust( $ts, $timecorrection );