28use Wikimedia\Timestamp\ConvertibleTimestamp;
46 return new static( $ts );
70 if (
$lang ===
null ) {
71 $lang = RequestContext::getMain()->getLanguage();
74 return $lang->getHumanTimestamp( $this, $relativeTo, $user );
86 $option = MediaWikiServices::getInstance()
87 ->getUserOptionsLookup()
88 ->getOption( $user,
'timecorrection' );
93 MediaWikiServices::getInstance()->getMainConfig()->
get(
'LocalTZoffset' )
95 $tz = $value->getTimeZone();
97 $this->timestamp->setTimezone( $tz );
98 return new DateInterval(
'P0Y' );
100 $interval = $value->getTimeOffsetInterval();
101 $this->timestamp->add( $interval );
119 array $chosenIntervals = []
121 if ( $relativeTo ===
null ) {
122 $relativeTo =
new self;
124 if ( $user ===
null ) {
125 $user = RequestContext::getMain()->getUser();
127 if (
$lang ===
null ) {
128 $lang = RequestContext::getMain()->getLanguage();
132 $diff = $this->diff( $relativeTo );
135 if ( Hooks::runner()->onGetRelativeTimestamp(
136 $ts, $diff, $this, $relativeTo, $user,
$lang )
138 $seconds = ( ( ( $diff->days * 24 + $diff->h ) * 60 + $diff->i ) * 60 + $diff->s );
139 $ts =
wfMessage(
'ago',
$lang->formatDuration( $seconds, $chosenIntervals ) )
140 ->inLanguage(
$lang )->text();
156 $tzMsg = $this->format(
'T' );
157 $key =
'timezone-' . strtolower( trim( $tzMsg ) );
159 if ( $msg->exists() ) {
175 $timestamp =
new self( $ts );
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Library for creating and parsing MW-style timestamps.
offsetForUser(UserIdentity $user)
Adjust the timestamp depending on the given user's preferences.
static getInstance( $ts=false)
Get a timestamp instance in GMT.
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
getHumanTimestamp(MWTimestamp $relativeTo=null, UserIdentity $user=null, Language $lang=null)
Get the timestamp in a human-friendly relative format, e.g., "3 days ago".
getTimezoneMessage()
Get the localized timezone message, if available.
getRelativeTimestamp(MWTimestamp $relativeTo=null, UserIdentity $user=null, Language $lang=null, array $chosenIntervals=[])
Generate a purely relative timestamp, i.e., represent the time elapsed between the given base timesta...
Variant of the Message class.
static newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.
if(!isset( $args[0])) $lang