|
MediaWiki
REL1_23
|
Library for creating and parsing MW-style timestamps. More...
Public Member Functions | |
| __construct ($timestamp=false) | |
| Make a new timestamp and set it to the specified time, or the current time if unspecified. | |
| __toString () | |
| diff (MWTimestamp $relativeTo) | |
| Calculate the difference between two MWTimestamp objects. | |
| format ($format) | |
| Format the timestamp in a given format. | |
| getHumanTimestamp (MWTimestamp $relativeTo=null, User $user=null, Language $lang=null) | |
| Get the timestamp in a human-friendly relative format, e.g., "3 days ago". | |
| getRelativeTimestamp (MWTimestamp $relativeTo=null, User $user=null, Language $lang=null, array $chosenIntervals=array()) | |
| Generate a purely relative timestamp, i.e., represent the time elapsed between the given base timestamp and this object. | |
| getTimestamp ($style=TS_UNIX) | |
| Get the timestamp represented by this object in a certain form. | |
| getTimezone () | |
| Get the timezone of this timestamp. | |
| offsetForUser (User $user) | |
| Adjust the timestamp depending on the given user's preferences. | |
| setTimestamp ($ts=false) | |
| Set the timestamp to the specified time, or the current time if unspecified. | |
| setTimezone ($timezone) | |
| Set the timezone of this timestamp to the specified timezone. | |
Static Public Member Functions | |
| static | getInstance ($ts=false) |
| Get a timestamp instance in GMT. | |
| static | getLocalInstance ($ts=false) |
| Get a timestamp instance in the server local timezone ($wgLocaltimezone) | |
Public Attributes | |
| DateTime | $timestamp |
| The actual timestamp being wrapped (DateTime object). | |
Static Private Attributes | |
| static | $formats |
| Standard gmdate() formats for the different timestamp types. | |
Library for creating and parsing MW-style timestamps.
Based on the JS library that does the same thing.
Definition at line 31 of file MWTimestamp.php.
| MWTimestamp::__construct | ( | $ | timestamp = false | ) |
Make a new timestamp and set it to the specified time, or the current time if unspecified.
| bool | string | $timestamp | Timestamp to set, or false for current time |
Definition at line 60 of file MWTimestamp.php.
| MWTimestamp::diff | ( | MWTimestamp $ | relativeTo | ) |
Calculate the difference between two MWTimestamp objects.
| MWTimestamp | $relativeTo | Base time to calculate difference from |
Definition at line 326 of file MWTimestamp.php.
| MWTimestamp::format | ( | $ | format | ) |
Format the timestamp in a given format.
| string | $format | Pattern to format in |
Definition at line 362 of file MWTimestamp.php.
| MWTimestamp::getHumanTimestamp | ( | MWTimestamp $ | relativeTo = null, |
| User $ | user = null, |
||
| Language $ | lang = null |
||
| ) |
Get the timestamp in a human-friendly relative format, e.g., "3 days ago".
Determine the difference between the timestamp and the current time, and generate a readable timestamp by returning "<N> <units> ago", where the largest possible unit is used.
| MWTimestamp | null | $relativeTo | The base timestamp to compare to (defaults to now) |
| User | null | $user | User the timestamp is being generated for (or null to use main context's user) |
| Language | null | $lang | Language to use to make the human timestamp (or null to use main context's language) |
Definition at line 178 of file MWTimestamp.php.
| static MWTimestamp::getInstance | ( | $ | ts = false | ) | [static] |
Get a timestamp instance in GMT.
| bool | string | $ts | Timestamp to set, or false for current time |
Definition at line 387 of file MWTimestamp.php.
Referenced by Xml\dateMenu(), and ReverseChronologicalPager\getDateCond().
| static MWTimestamp::getLocalInstance | ( | $ | ts = false | ) | [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 373 of file MWTimestamp.php.
Referenced by SpecialVersion\getCopyrightAndAuthorList(), Preferences\getTimezoneOptions(), CoreParserFunctions\revisionday(), CoreParserFunctions\revisionday2(), CoreParserFunctions\revisionmonth(), CoreParserFunctions\revisionmonth1(), CoreParserFunctions\revisiontimestamp(), CoreParserFunctions\revisionyear(), and UserMailer\send().
| MWTimestamp::getRelativeTimestamp | ( | MWTimestamp $ | relativeTo = null, |
| User $ | user = null, |
||
| Language $ | lang = null, |
||
| array $ | chosenIntervals = array() |
||
| ) |
Generate a purely relative timestamp, i.e., represent the time elapsed between the given base timestamp and this object.
| MWTimestamp | $relativeTo | Relative base timestamp (defaults to now) |
| User | $user | Use to use offset for |
| Language | $lang | Language to use |
| array | $chosenIntervals | Intervals to use to represent it |
Definition at line 282 of file MWTimestamp.php.
| MWTimestamp::getTimestamp | ( | $ | style = TS_UNIX | ) |
Get the timestamp represented by this object in a certain form.
Convert the internal timestamp to the specified format and then return it.
| int | $style | Constant Output format for timestamp |
| TimestampException |
Definition at line 149 of file MWTimestamp.php.
Get the timezone of this timestamp.
Definition at line 351 of file MWTimestamp.php.
| MWTimestamp::offsetForUser | ( | User $ | user | ) |
Adjust the timestamp depending on the given user's preferences.
| User | $user | User to take preferences from | |
| [out] | MWTimestamp | $ts | Timestamp to adjust |
Definition at line 214 of file MWTimestamp.php.
| MWTimestamp::setTimestamp | ( | $ | ts = false | ) |
Set the timestamp to the specified time, or the current time if unspecified.
Parse the given timestamp into either a DateTime object or a Unix timestamp, and then store it.
| string | bool | $ts | Timestamp to store, or false for now |
| TimestampException |
Definition at line 75 of file MWTimestamp.php.
| MWTimestamp::setTimezone | ( | $ | timezone | ) |
Set the timezone of this timestamp to the specified timezone.
| String | $timezone | Timezone to set |
| TimestampException |
Definition at line 337 of file MWTimestamp.php.
MWTimestamp::$formats [static, private] |
array( TS_UNIX => 'U', TS_MW => 'YmdHis', TS_DB => 'Y-m-d H:i:s', TS_ISO_8601 => 'Y-m-d\TH:i:s\Z', TS_ISO_8601_BASIC => 'Ymd\THis\Z', TS_EXIF => 'Y:m:d H:i:s', TS_RFC2822 => 'D, d M Y H:i:s', TS_ORACLE => 'd-m-Y H:i:s.000000', TS_POSTGRES => 'Y-m-d H:i:s', )
Standard gmdate() formats for the different timestamp types.
Definition at line 35 of file MWTimestamp.php.
| DateTime MWTimestamp::$timestamp |
The actual timestamp being wrapped (DateTime object).
Definition at line 50 of file MWTimestamp.php.