MediaWiki fundraising/REL1_35
TimeUnits Class Reference

A class for querying translated time units from CLDR data. More...

Inheritance diagram for TimeUnits:
Collaboration diagram for TimeUnits:

Static Public Member Functions

static getUnits ( $code)
 Get localized time units for a particular language, using fallback languages for missing items.
 
static onGetHumanTimestamp (&$output, $timestamp, $relativeTo, $user, $lang)
 Handler for GetHumanTimestamp hook.
 
- Static Public Member Functions inherited from CldrNames
static getFileName ( $code)
 Get the name for the file that contains the CLDR data for a given language.
 
static getOverrideFileName ( $code)
 Get the name for the file that contains the local override data for a given language.
 

Static Private Member Functions

static loadLanguage ( $code)
 Load time units localized for a particular language.
 

Static Private Attributes

static $cache = []
 

Detailed Description

A class for querying translated time units from CLDR data.

Author
Niklas Laxström
Ryan Kaldari
Note
Copyright © 2007-2013
GPL-2.0-or-later

Definition at line 11 of file TimeUnits.php.

Member Function Documentation

◆ getUnits()

static TimeUnits::getUnits ( $code)
static

Get localized time units for a particular language, using fallback languages for missing items.

The time units are returned as an associative array. The keys are of the form: <unit>-<tense>-<ordinality> (for example, 'hour-future-two'). The values include a placeholder for the number (for example, '{0} months ago').

Parameters
string$codeThe language to return the list in
Returns
array an associative array of time unit codes and localized time units

Definition at line 24 of file TimeUnits.php.

References $fallback, and loadLanguage().

Referenced by onGetHumanTimestamp().

◆ loadLanguage()

static TimeUnits::loadLanguage ( $code)
staticprivate

Load time units localized for a particular language.

Helper function for getUnits.

Parameters
string$codeThe language to return the list in
Returns
array an associative array of time unit codes and localized time units

Definition at line 50 of file TimeUnits.php.

References $timeUnits, CldrNames\getFileName(), CldrNames\getOverrideFileName(), and wfDebug().

Referenced by getUnits().

◆ onGetHumanTimestamp()

static TimeUnits::onGetHumanTimestamp ( & $output,
$timestamp,
$relativeTo,
$user,
$lang )
static

Handler for GetHumanTimestamp hook.

Converts the given time into a human-friendly relative format, for example, '6 days ago', 'In 10 months'.

Parameters
string&$outputThe output timestamp
MWTimestamp$timestampThe current (user-adjusted) timestamp
MWTimestamp$relativeToThe relative (user-adjusted) timestamp
User$userUser whose preferences are being used to make timestamp
Language$langLanguage that will be used to render the timestamp
Returns
bool False means the timestamp was overridden so stop further processing. True means the timestamp was not overridden.

Definition at line 96 of file TimeUnits.php.

References $lang, $timeUnits, getUnits(), and wfMessage().

Member Data Documentation

◆ $cache

TimeUnits::$cache = []
staticprivate

Definition at line 13 of file TimeUnits.php.


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