MediaWiki REL1_28
|
Library for creating, parsing, and converting 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 (ConvertibleTimestamp $relativeTo) | |
Calculate the difference between two ConvertibleTimestamp objects. | |
format ( $format) | |
Format the timestamp in a given format. | |
getTimestamp ( $style=TS_UNIX) | |
Get the timestamp represented by this object in a certain form. | |
getTimezone () | |
Get the timezone of this timestamp. | |
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 | convert ( $style=TS_UNIX, $ts) |
Convert a timestamp string to a given format. | |
static | now ( $style=TS_MW) |
Get the current time in the given format. | |
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, parsing, and converting timestamps.
Based on the JS library that does the same thing.
Definition at line 31 of file ConvertibleTimestamp.php.
ConvertibleTimestamp::__construct | ( | $timestamp = false | ) |
Make a new timestamp and set it to the specified time, or the current time if unspecified.
bool | string | int | float | DateTime | $timestamp | Timestamp to set, or false for current time |
Definition at line 59 of file ConvertibleTimestamp.php.
References $timestamp, and setTimestamp().
ConvertibleTimestamp::__toString | ( | ) |
|
static |
Convert a timestamp string to a given format.
int | $style | Constant Output format for timestamp |
string | $ts | Timestamp |
Definition at line 171 of file ConvertibleTimestamp.php.
References $e.
Referenced by Database\decodeExpiry(), FileBackendStore\setFileCache(), ConvertibleTimestampTest\testConvert(), ConvertibleTimestampTest\testConvertInvalid(), XMPValidate\validateDate(), and wfTimestamp().
ConvertibleTimestamp::diff | ( | ConvertibleTimestamp | $relativeTo | ) |
Calculate the difference between two ConvertibleTimestamp objects.
ConvertibleTimestamp | $relativeTo | Base time to calculate difference from |
Definition at line 233 of file ConvertibleTimestamp.php.
Referenced by Language\getHumanTimestampInternal().
ConvertibleTimestamp::format | ( | $format | ) |
Format the timestamp in a given format.
string | $format | Pattern to format in |
Definition at line 266 of file ConvertibleTimestamp.php.
Referenced by Language\getHumanTimestampInternal(), and MWTimestamp\getTimezoneMessage().
ConvertibleTimestamp::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 200 of file ConvertibleTimestamp.php.
References $output, TS_MW, TS_POSTGRES, and TS_RFC2822.
Referenced by __toString(), and Language\getHumanTimestampInternal().
ConvertibleTimestamp::getTimezone | ( | ) |
Get the timezone of this timestamp.
Definition at line 256 of file ConvertibleTimestamp.php.
|
static |
Get the current time in the given format.
int | $style | Constant Output format for timestamp |
Definition at line 186 of file ConvertibleTimestamp.php.
Referenced by wfTimestampNow().
ConvertibleTimestamp::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 76 of file ConvertibleTimestamp.php.
Referenced by __construct().
ConvertibleTimestamp::setTimezone | ( | $timezone | ) |
Set the timezone of this timestamp to the specified timezone.
string | $timezone | Timezone to set |
TimestampException |
Definition at line 243 of file ConvertibleTimestamp.php.
References $e.
|
staticprivate |
Standard gmdate() formats for the different timestamp types.
Definition at line 35 of file ConvertibleTimestamp.php.
DateTime ConvertibleTimestamp::$timestamp |
The actual timestamp being wrapped (DateTime object).
Definition at line 51 of file ConvertibleTimestamp.php.
Referenced by __construct(), and MWTimestamp\getLocalInstance().