function oa_date_format_date in Open Atrium Core 7.2
Helper function to render the relative date.
2 calls to oa_date_format_date()
- oa_date_handler_field_date::render in modules/
oa_date/ views/ oa_date_handler_field_date.inc - Override of render().
- oa_user_submitted_render in modules/
oa_users/ plugins/ content_types/ oa_users_submitted.inc - Run-time rendering of the body of the block (content type) See ctools_plugin_examples for more advanced info
File
- modules/
oa_date/ oa_date.module, line 42 - Provides hook implementations and functionality to oa_date.
Code
function oa_date_format_date($timestamp) {
static $dates;
if (!isset($dates)) {
$dates = array(
'today' => strtotime("today"),
'yesterday' => strtotime("yesterday"),
'year' => strtotime("first day of January"),
);
}
if ($timestamp >= $dates['today']) {
return t("Today") . format_date($timestamp, 'custom', ', F j');
}
elseif ($timestamp >= $dates['yesterday']) {
return t("Yesterday") . format_date($timestamp, 'custom', ', F j');
}
elseif ($timestamp < $dates['year']) {
// only add year to dates from previous years
return format_date($timestamp, 'custom', 'l, F j Y');
}
else {
return format_date($timestamp, 'custom', 'l, F j');
}
}