function partial_date_day_ordinal_suffix in Partial Date 7
Returns a translated ordinal suffix for a given day of the month.
1 call to partial_date_day_ordinal_suffix()
File
- ./
partial_date.module, line 1255 - Defines a date element that allows for any combination of date granularity settings.
Code
function partial_date_day_ordinal_suffix($day) {
if (empty($day)) {
return '';
}
static $suffixes;
if (empty($suffixes)) {
$suffixes = array(
'st' => t('st', array(), array(
'context' => 'ordinal abbreviation',
)),
'nd' => t('nd', array(), array(
'context' => 'ordinal abbreviation',
)),
'rd' => t('rd', array(), array(
'context' => 'ordinal abbreviation',
)),
'th' => t('th', array(), array(
'context' => 'ordinal abbreviation',
)),
);
}
switch (($day = abs($day)) % 100) {
case 11:
case 12:
case 13:
return $suffixes['th'];
default:
switch ($day % 10) {
case 1:
return $suffixes['st'];
case 2:
return $suffixes['nd'];
case 3:
return $suffixes['rd'];
default:
return $suffixes['th'];
}
}
}