MediaWiki master
MediaWiki\User\UserTimeCorrection Class Reference

Utility class to parse the TimeCorrection string value. More...

Inherits Stringable.

Collaboration diagram for MediaWiki\User\UserTimeCorrection:

Public Member Functions

 __construct (string $timeCorrection, DateTime $relativeToDate=null, int $systemOffset=0)
 
 __toString ()
 
 getCorrectionType ()
 Get time offset for a user.
 
 getTimeOffset ()
 Get corresponding time offset for this correction Note: When correcting dates/times, apply only the offset OR the time zone, not both.
 
 getTimeOffsetInterval ()
 Get corresponding time offset for this correction Note: When correcting dates/times, apply only the offset OR the time zone, not both.
 
 getTimeZone ()
 The time zone if known Note: When correcting dates/times, apply only the offset OR the time zone, not both.
 
 isValid ()
 Was the original correction specification valid.
 
 toString ()
 Note: The string value of this object might not be equal to the original value.
 

Static Public Member Functions

static formatTimezoneOffset (int $offset)
 Converts a timezone offset in minutes (e.g., "120") to an hh:mm string like "+02:00".
 

Detailed Description

Utility class to parse the TimeCorrection string value.

These values are used to specify the time offset for a user and are stored in the database as a user preference and returned by the preferences APIs

The class will correct invalid input and adjusts timezone offsets to applicable dates, taking into account DST etc.

Since
1.37

Definition at line 44 of file UserTimeCorrection.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\UserTimeCorrection::__construct ( string $timeCorrection,
DateTime $relativeToDate = null,
int $systemOffset = 0 )
Parameters
string$timeCorrectionOriginal time correction string
DateTime | null$relativeToDateThe date used to calculate the time zone offset of. This defaults to the current date and time.
int$systemOffsetOffset for self::SYSTEM in minutes

Definition at line 79 of file UserTimeCorrection.php.

Member Function Documentation

◆ __toString()

MediaWiki\User\UserTimeCorrection::__toString ( )

Definition at line 267 of file UserTimeCorrection.php.

◆ formatTimezoneOffset()

static MediaWiki\User\UserTimeCorrection::formatTimezoneOffset ( int $offset)
static

Converts a timezone offset in minutes (e.g., "120") to an hh:mm string like "+02:00".

Parameters
int$offset
Returns
string

Definition at line 244 of file UserTimeCorrection.php.

◆ getCorrectionType()

MediaWiki\User\UserTimeCorrection::getCorrectionType ( )

Get time offset for a user.

Returns
string Offset that was applied to the user

Definition at line 94 of file UserTimeCorrection.php.

◆ getTimeOffset()

MediaWiki\User\UserTimeCorrection::getTimeOffset ( )

Get corresponding time offset for this correction Note: When correcting dates/times, apply only the offset OR the time zone, not both.

Returns
int Offset in minutes

Definition at line 103 of file UserTimeCorrection.php.

◆ getTimeOffsetInterval()

MediaWiki\User\UserTimeCorrection::getTimeOffsetInterval ( )

Get corresponding time offset for this correction Note: When correcting dates/times, apply only the offset OR the time zone, not both.

Returns
DateInterval Offset in minutes as a DateInterval

Definition at line 112 of file UserTimeCorrection.php.

◆ getTimeZone()

MediaWiki\User\UserTimeCorrection::getTimeZone ( )

The time zone if known Note: When correcting dates/times, apply only the offset OR the time zone, not both.

Returns
DateTimeZone|null

Definition at line 126 of file UserTimeCorrection.php.

◆ isValid()

MediaWiki\User\UserTimeCorrection::isValid ( )

Was the original correction specification valid.

Returns
bool

Definition at line 134 of file UserTimeCorrection.php.

◆ toString()

MediaWiki\User\UserTimeCorrection::toString ( )

Note: The string value of this object might not be equal to the original value.

Returns
string a timecorrection string representing this value

Definition at line 253 of file UserTimeCorrection.php.


The documentation for this class was generated from the following file: