function calendar_systems_format_date in Calendar Systems 6.2
Same name and namespace in other branches
- 8 calendar_systems.module \calendar_systems_format_date()
- 5 calendar_systems.module \calendar_systems_format_date()
- 6.3 calendar_systems.module \calendar_systems_format_date()
- 6 calendar_systems.module \calendar_systems_format_date()
- 7.3 calendar_systems.module \calendar_systems_format_date()
- 7 calendar_systems.module \calendar_systems_format_date()
- 7.2 calendar_systems.module \calendar_systems_format_date()
Implements hook_format_date().
This is a temporary hook implementation which employs a procedural concept of Factory design pattern until we all get a better format_date() function at Drupal core. Till those days we need to patch the includes/common.inc file to provide the ability to implement hook_format_date().
Parameters
$timestamp: Unix timestamp to be formatted. The proper timezone value has been added to this by format_date().
$timezone: Timezone offset in seconds.
$format: PHP date() function format string.
$langcode: Optional language code to translate to a language other than the default.
Return value
The formatted date or FALSE otherwise.
See also
patch/common.inc-format_date.d6.patch
File
- ./
calendar_systems.module, line 139 - Contains Calendar Systems module hooks, helpers and API functions.
Code
function calendar_systems_format_date($timestamp, $format, $timezone = NULL, $langcode = NULL) {
// Cherrypick the best-fit calendar for current user/language
// combination and call its formatter callback, if available.
$calendar = calendar_systems_pick();
if (isset($calendar['format callback']) && function_exists($calendar['format callback'])) {
return $calendar['format callback']($timestamp, $format, $timezone, $langcode, $calendar);
}
// Unexpected failure! Falling back to format_date() itself.
return FALSE;
}