Go to the documentation of this file.
24 use Wikimedia\Timestamp\ConvertibleTimestamp;
40 return new static( $ts );
64 if (
$lang ===
null ) {
68 return $lang->getHumanTimestamp( $this, $relativeTo,
$user );
82 $option =
$user->getOption(
'timecorrection' );
83 $data = explode(
'|', $option, 3 );
86 if ( $data[0] ==
'ZoneInfo' ) {
88 $tz =
new DateTimeZone( $data[2] );
89 }
catch ( Exception
$e ) {
94 $this->timestamp->setTimezone( $tz );
95 return new DateInterval(
'P0Y' );
104 if ( $data[0] ==
'System' ) {
109 } elseif ( $data[0] ==
'Offset' ) {
111 $diff = (int)$data[1];
115 $data = explode(
':', $option );
116 if (
count( $data ) >= 2 ) {
118 $diff = abs( (
int)$data[0] ) * 60 + (int)$data[1];
119 if ( (
int)$data[0] < 0 ) {
124 $diff = (int)$data[0] * 60;
128 $interval =
new DateInterval(
'PT' . abs( $diff ) .
'M' );
130 $interval->invert = 1;
133 $this->timestamp->add( $interval );
151 array $chosenIntervals = []
153 if ( $relativeTo ===
null ) {
154 $relativeTo =
new self;
156 if (
$user ===
null ) {
159 if (
$lang ===
null ) {
164 $diff = $this->
diff( $relativeTo );
166 'GetRelativeTimestamp',
167 [ &$ts, &$diff, $this, $relativeTo,
$user,
$lang ]
169 $seconds = ( ( ( $diff->days * 24 + $diff->h ) * 60 + $diff->i ) * 60 + $diff->s );
170 $ts =
wfMessage(
'ago',
$lang->formatDuration( $seconds, $chosenIntervals ) )
171 ->inLanguage(
$lang )->text();
187 $tzMsg = $this->
format(
'T' );
188 $key =
'timezone-' . strtolower( trim( $tzMsg ) );
190 if ( $msg->exists() ) {
206 $timestamp =
new self( $ts );
getTimezoneMessage()
Get the localized timezone message, if available.
Library for creating and parsing MW-style timestamps.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
if(!isset( $args[0])) $lang
also included in $newHeader if any indicating whether we should show just the diff
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
offsetForUser(User $user)
Adjust the timestamp depending on the given user's preferences.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static getInstance( $ts=false)
Get a timestamp instance in GMT.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
getRelativeTimestamp(MWTimestamp $relativeTo=null, User $user=null, Language $lang=null, array $chosenIntervals=[])
Generate a purely relative timestamp, i.e., represent the time elapsed between the given base timesta...
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
static getMain()
Get the RequestContext object associated with the main request.
if the prop value should be in the metadata multi language array format
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
Variant of the Message class.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
getHumanTimestamp(MWTimestamp $relativeTo=null, User $user=null, Language $lang=null)
Get the timestamp in a human-friendly relative format, e.g., "3 days ago".
Internationalisation code.