91// Context passed over from the parser 92 ConvertibleTimestamp $ts,
94 LoggerInterface $logger
96 $pageLang = $parser->getTargetLanguage();
98 $cacheTTL = self::CACHE_TTL_BY_ID[$id] ?? -1;
99if ( $cacheTTL > -1 ) {
100 $parser->
getOutput()->updateCacheExpiry( $cacheTTL );
109 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
111return $pageLang->formatNumNoSeparators( $ts->format(
'm' ) );
113 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
115return $pageLang->formatNumNoSeparators( $ts->format(
'n' ) );
116case'currentmonthname':
117 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
119return $pageLang->getMonthName( (
int)$ts->format(
'n' ) );
120case'currentmonthnamegen':
121 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
123return $pageLang->getMonthNameGen( (
int)$ts->format(
'n' ) );
124case'currentmonthabbrev':
125 self::applyUnitTimestampDeadline( $parser, $ts,
'M' );
127return $pageLang->getMonthAbbreviation( (
int)$ts->format(
'n' ) );
129 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
131return $pageLang->formatNumNoSeparators( $ts->format(
'j' ) );
133 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
135return $pageLang->formatNumNoSeparators( $ts->format(
'd' ) );
137 $localTs = self::makeTsLocal( $svcOptions, $ts );
138 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
140return $pageLang->formatNumNoSeparators( $localTs->format(
'm' ) );
142 $localTs = self::makeTsLocal( $svcOptions, $ts );
143 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
145return $pageLang->formatNumNoSeparators( $localTs->format(
'n' ) );
147 $localTs = self::makeTsLocal( $svcOptions, $ts );
148 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
150return $pageLang->getMonthName( (
int)$localTs->format(
'n' ) );
151case'localmonthnamegen':
152 $localTs = self::makeTsLocal( $svcOptions, $ts );
153 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
155return $pageLang->getMonthNameGen( (
int)$localTs->format(
'n' ) );
156case'localmonthabbrev':
157 $localTs = self::makeTsLocal( $svcOptions, $ts );
158 self::applyUnitTimestampDeadline( $parser, $localTs,
'M' );
160return $pageLang->getMonthAbbreviation( (
int)$localTs->format(
'n' ) );
162 $localTs = self::makeTsLocal( $svcOptions, $ts );
163 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
165return $pageLang->formatNumNoSeparators( $localTs->format(
'j' ) );
167 $localTs = self::makeTsLocal( $svcOptions, $ts );
168 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
170return $pageLang->formatNumNoSeparators( $localTs->format(
'd' ) );
183case'subjectpagename':
184case'subjectpagenamee':
193case'revisiontimestamp':
196case'namespacenumber':
201case'cascadingsources':
202 # First argument of the corresponding parser function 203 # (second argument of the PHP implementation) is 206 # Note that for many of these {{FOO}} is subtly different 207 # from {{FOO:{{PAGENAME}}}}, so we can't pass $title here 208 # we have to explicitly use the "no arguments" form of the 209 # parser function by passing `null` to indicate a missing 210 # argument (which then defaults to the current page title). 211return CoreParserFunctions::$id( $parser,
null );
215 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
217return $pageLang->getWeekdayName( (
int)$ts->format(
'w' ) + 1 );
219 self::applyUnitTimestampDeadline( $parser, $ts,
'Y' );
221return $pageLang->formatNumNoSeparators( $ts->format(
'Y' ) );
223return $pageLang->time( $ts->getTimestamp( TS_MW ),
false,
false );
225 self::applyUnitTimestampDeadline( $parser, $ts,
'H' );
227return $pageLang->formatNumNoSeparators( $ts->format(
'H' ) );
229 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
230// @bug T6594 PHP5 has it zero padded, PHP4 does not, cast to 231// int to remove the padding 232return $pageLang->formatNum( (
int)$ts->format(
'W' ) );
234 self::applyUnitTimestampDeadline( $parser, $ts,
'D' );
236return $pageLang->formatNum( $ts->format(
'w' ) );
238 $localTs = self::makeTsLocal( $svcOptions, $ts );
239 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
241return $pageLang->getWeekdayName( (
int)$localTs->format(
'w' ) + 1 );
243 $localTs = self::makeTsLocal( $svcOptions, $ts );
244 self::applyUnitTimestampDeadline( $parser, $localTs,
'Y' );
246return $pageLang->formatNumNoSeparators( $localTs->format(
'Y' ) );
248 $localTs = self::makeTsLocal( $svcOptions, $ts );
250return $pageLang->time(
251 $localTs->format(
'YmdHis' ),
256 $localTs = self::makeTsLocal( $svcOptions, $ts );
257 self::applyUnitTimestampDeadline( $parser, $localTs,
'H' );
259return $pageLang->formatNumNoSeparators( $localTs->format(
'H' ) );
261 $localTs = self::makeTsLocal( $svcOptions, $ts );
262 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
263// @bug T6594 PHP5 has it zero padded, PHP4 does not, cast to 264// int to remove the padding 265return $pageLang->formatNum( (
int)$localTs->format(
'W' ) );
267 $localTs = self::makeTsLocal( $svcOptions, $ts );
268 self::applyUnitTimestampDeadline( $parser, $localTs,
'D' );
270return $pageLang->formatNum( $localTs->format(
'w' ) );
271case'numberofarticles':
274case'numberofactiveusers':
278 # second argument is 'raw'; magic variables are "not raw" 279return CoreParserFunctions::$id( $parser,
null );
280case'currenttimestamp':
281return $ts->getTimestamp( TS_MW );
283 $localTs = self::makeTsLocal( $svcOptions, $ts );
285return $localTs->format(
'YmdHis' );
287return SpecialVersion::getVersion();
301return $pageLang->getDirMark();
302case'contentlanguage':
305return $pageLang->getCode();
312return $pageLang->getCode();
317 # magic variables are the same as empty/default first argument 318return CoreParserFunctions::$id( $parser );
320// This is not one of the core magic variables