MediaWiki
master
|
Library for creating and parsing MW-style timestamps. More...
Public Member Functions | |
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 timestamp and this object. More... | |
getTimezoneMessage () | |
Get the localized timezone message, if available. More... | |
offsetForUser (UserIdentity $user) | |
Adjust the timestamp depending on the given user's preferences. More... | |
Static Public Member Functions | |
static | getInstance ( $ts=false) |
Get a timestamp instance in GMT. More... | |
static | getLocalInstance ( $ts=false) |
Get a timestamp instance in the server local timezone ($wgLocaltimezone) More... | |
Library for creating and parsing MW-style timestamps.
Based on the JS library that does the same thing.
Definition at line 41 of file MWTimestamp.php.
|
static |
Get a timestamp instance in GMT.
bool | string | $ts | Timestamp to set, or false for current time |
Definition at line 48 of file MWTimestamp.php.
Referenced by Xml\dateMenu(), MediaWiki\Specials\SpecialLog\execute(), WikiBirthday\execute(), RangeChronologicalPager\getDateRangeCond(), ReverseChronologicalPager\getOffsetDate(), and FileRepo\storeTemp().
|
static |
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
bool | string | $ts | Timestamp to set, or false for current time |
Definition at line 142 of file MWTimestamp.php.
Referenced by SpecialVersion\getCopyrightAndAuthorList(), RevertAction\getFormFields(), and UserMailer\sendInternal().
MWTimestamp::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 timestamp and this object.
MWTimestamp | null | $relativeTo | Relative base timestamp (defaults to now) |
UserIdentity | null | $user | Use to use offset for |
Language | null | $lang | Language to use |
array | $chosenIntervals | Intervals to use to represent it |
Definition at line 90 of file MWTimestamp.php.
References $lang, RequestContext\getMain(), User\newFromIdentity(), and wfMessage().
MWTimestamp::getTimezoneMessage | ( | ) |
Get the localized timezone message, if available.
Premade translations are not shipped as format() may return whatever the system uses, localized or not, so translation must be done through wiki.
Definition at line 124 of file MWTimestamp.php.
References wfMessage().
MWTimestamp::offsetForUser | ( | UserIdentity | $user | ) |
Adjust the timestamp depending on the given user's preferences.
UserIdentity | $user | User to take preferences from |
Definition at line 60 of file MWTimestamp.php.
Referenced by Language\getHumanTimestamp().