function calendar_systems_formatter in Calendar Systems 6.2
API function acting as a fallback for 3rdparty Calendar Systems modules.
Modules formatter callbacks that does not define a particular format should pass the format to this API function, so the timestamp will get formatted by the default formatter.
@todo
- Pass it through the format_date() once it got improved.
Parameters
$timestamp: Unix timestamp to be formatted.
$format: Date format as required by PHP date().
$timezone: Time zone offset in seconds.
Return value
Formatted date based on the passed $format.
1 call to calendar_systems_formatter()
- calendar_jalali_formatter in calendars/
calendar_jalali/ calendar_jalali.module - Jalali calendar date formatter callback.
File
- ./
calendar_systems.module, line 390 - Contains Calendar Systems module hooks, helpers and API functions.
Code
function calendar_systems_formatter($timestamp, $format, $timezone = 0) {
$date = '';
$max = strlen($format);
for ($i = 0; $i < $max; $i++) {
$c = $format[$i];
if (strpos('AaDlM', $c) !== FALSE) {
$date .= t(gmdate($c, $timestamp), array(), $langcode);
}
elseif ($c == 'F') {
$date .= trim(t('!long-month-name ' . gmdate($c, $timestamp), array(
'!long-month-name' => '',
), $langcode));
}
elseif (strpos('BdgGhHiIjLmnsStTUwWYyz', $c) !== FALSE) {
$date .= gmdate($c, $timestamp);
}
elseif ($c == 'r') {
$date .= format_date($timestamp - $timezone, 'custom', 'D, d M Y H:i:s O', $timezone, $langcode);
}
elseif ($c == 'O') {
$date .= sprintf('%s%02d%02d', $timezone < 0 ? '-' : '+', abs($timezone / 3600), abs($timezone % 3600) / 60);
}
elseif ($c == 'Z') {
$date .= $timezone;
}
elseif ($c == '\\') {
$date .= $format[++$i];
}
else {
$date .= date($c, $timestamp);
}
}
return $date;
}