summaryrefslogtreecommitdiff
path: root/extensions/ParserFunctions/ParserFunctions_body.php
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/ParserFunctions/ParserFunctions_body.php')
-rw-r--r--extensions/ParserFunctions/ParserFunctions_body.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/extensions/ParserFunctions/ParserFunctions_body.php b/extensions/ParserFunctions/ParserFunctions_body.php
index 879b7a15..967e8339 100644
--- a/extensions/ParserFunctions/ParserFunctions_body.php
+++ b/extensions/ParserFunctions/ParserFunctions_body.php
@@ -452,10 +452,10 @@ class ExtParserFunctions {
} else {
$tz = new DateTimeZone( date_default_timezone_get() );
}
- $dateObject->setTimezone( $tz );
} else {
- $dateObject->setTimezone( $utc );
+ $tz = $utc;
}
+ $dateObject->setTimezone( $tz );
# Generate timestamp
$ts = $dateObject->format( 'YmdHis' );
@@ -471,14 +471,16 @@ class ExtParserFunctions {
if ( self::$mTimeChars > self::$mMaxTimeChars ) {
return '<strong class="error">' . wfMessage( 'pfunc_time_too_long' )->inContentLanguage()->escaped() . '</strong>';
} else {
- if ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
+ if ( $ts < 0 ) { // Language can't deal with BC years
+ return '<strong class="error">' . wfMessage( 'pfunc_time_too_small' )->inContentLanguage()->escaped() . '</strong>';
+ } elseif ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
if ( $language !== '' && Language::isValidBuiltInCode( $language ) ) {
// use whatever language is passed as a parameter
$langObject = Language::factory( $language );
- $result = $langObject->sprintfDate( $format, $ts );
+ $result = $langObject->sprintfDate( $format, $ts, $tz );
} else {
// use wiki's content language
- $result = $parser->getFunctionLang()->sprintfDate( $format, $ts );
+ $result = $parser->getFunctionLang()->sprintfDate( $format, $ts, $tz );
}
} else {
return '<strong class="error">' . wfMessage( 'pfunc_time_too_big' )->inContentLanguage()->escaped() . '</strong>';