38 TS_DB =>
'Y-m-d H:i:s',
82 if ( !$ts || $ts ===
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ) {
85 } elseif ( preg_match(
'/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/D', $ts, $da ) ) {
87 } elseif ( preg_match(
'/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/D', $ts, $da ) ) {
89 } elseif ( preg_match(
'/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D', $ts, $da ) ) {
91 } elseif ( preg_match(
'/^(-?\d{1,13})(\.\d+)?$/D', $ts, $m ) ) {
93 $strtime =
"@{$m[1]}";
94 } elseif ( preg_match(
'/^\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}.\d{6}$/', $ts ) ) {
95 # TS_ORACLE // session altered to DD-MM-YYYY HH24:MI:SS.FF6
96 $strtime = preg_replace(
'/(\d\d)\.(\d\d)\.(\d\d)(\.(\d+))?/',
"$1:$2:$3",
97 str_replace(
'+00:00',
'UTC', $ts ) );
98 } elseif ( preg_match(
99 '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.*\d*)?Z?$/',
104 } elseif ( preg_match(
105 '/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(?:\.*\d*)?Z?$/',
110 } elseif ( preg_match(
111 '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d*[\+\- ](\d\d)$/',
116 } elseif ( preg_match(
117 '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/',
122 } elseif ( preg_match(
124 '/^[ \t\r\n]*([A-Z][a-z]{2},[ \t\r\n]*)?' .
126 '\d\d?[ \t\r\n]*[A-Z][a-z]{2}[ \t\r\n]*\d{2}(?:\d{2})?' .
128 '[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d[ \t\r\n]*:[ \t\r\n]*\d\d/S',
131 # TS_RFC2822, accepting a trailing comment.
132 # See http://www.squid-cache.org/mail-archive/squid-users/200307/0122.html / r77171
133 # The regex is a superset of rfc2822 for readability
134 $strtime = strtok( $ts,
';' );
135 } elseif ( preg_match(
'/^[A-Z][a-z]{5,8}, \d\d-[A-Z][a-z]{2}-\d{2} \d\d:\d\d:\d\d/', $ts ) ) {
138 } elseif ( preg_match(
'/^[A-Z][a-z]{2} [A-Z][a-z]{2} +\d{1,2} \d\d:\d\d:\d\d \d{4}/', $ts ) ) {
146 $da = array_map(
'intval', $da );
147 $da[0] =
"%04d-%02d-%02dT%02d:%02d:%02d.00+00:00";
148 $strtime = call_user_func_array(
"sprintf", $da );
152 $final =
new DateTime( $strtime,
new DateTimeZone(
'GMT' ) );
157 if ( $final ===
false ) {
161 $this->timestamp = $final;
173 $ct =
new static( $ts );
174 return $ct->getTimestamp( $style );
187 return static::convert( $style, time() );
201 if ( !isset( self::$formats[$style] ) ) {
205 $output = $this->timestamp->format( self::$formats[$style] );
212 throw new TimestampException( __METHOD__ .
': The timestamp cannot be represented in ' .
213 'the specified format' );
234 return $this->timestamp->diff( $relativeTo->timestamp );
245 $this->timestamp->setTimezone(
new DateTimeZone( $timezone ) );
257 return $this->timestamp->getTimezone();
267 return $this->timestamp->format( $format );
Library for creating, parsing, and converting timestamps.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
setTimezone($timezone)
Set the timezone of this timestamp to the specified timezone.
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
DateTime $timestamp
The actual timestamp being wrapped (DateTime object).
static now($style=TS_MW)
Get the current time in the given format.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
diff(ConvertibleTimestamp $relativeTo)
Calculate the difference between two ConvertibleTimestamp objects.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
static $formats
Standard gmdate() formats for the different timestamp types.
getTimezone()
Get the timezone of this timestamp.
__construct($timestamp=false)
Make a new timestamp and set it to the specified time, or the current time if unspecified.
const TS_EXIF
An Exif timestamp (YYYY:MM:DD HH:MM:SS)
format($format)
Format the timestamp in a given format.
getTimestamp($style=TS_UNIX)
Get the timestamp represented by this object in a certain form.
const TS_ISO_8601_BASIC
ISO 8601 basic format with no timezone: 19860209T200000Z.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
setTimestamp($ts=false)
Set the timestamp to the specified time, or the current time if unspecified.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
const TS_POSTGRES
Postgres format time.
static convert($style=TS_UNIX, $ts)
Convert a timestamp string to a given format.
const TS_ORACLE
Oracle format time.
const TS_DB
MySQL DATETIME (YYYY-MM-DD HH:MM:SS)