function activity_format_offset in Activity 5.2
Same name and namespace in other branches
- 5.4 activity.module \activity_format_offset()
- 5.3 activity.module \activity_format_offset()
- 6 activity.module \activity_format_offset()
date formatter $timestamp is the unix timestamp() of when an activity occurred. $end is the human language formatted string expressing how long ago this was.
1 call to activity_format_offset()
- activity_page in ./
activity.module - Menu callback to display the records in a page
File
- ./
activity.module, line 380 - Activity module: Allow users to see their friends' activity on the site.
Code
function activity_format_offset($timestamp) {
$offset = strftime("%j") + strftime("%Y") * 365 - (strftime("%j", $timestamp) + strftime("%Y", $timestamp) * 365);
if ($offset >= 7) {
$offset = strftime("%V") + strftime("%Y") * 52 - (strftime("%V", $timestamp) + strftime("%Y", $timestamp) * 52);
$end = $offset != 0 ? format_plural($offset, t("a week ago"), t("@count weeks ago", array(
"@count" => $offset,
))) : t("Today");
}
else {
if ($offset > 0) {
$end = format_plural($offset, t('Yesterday'), t('@count days ago', array(
'@count' => $offset,
)));
}
else {
$end = t('Today');
}
}
return $end;
}