show exact date when needed

darcs-hash:20080627222930-84dde-e54a369d91060b7ff2559af9ff08735b2eec43d9.gz
This commit is contained in:
Evan Prodromou 2008-06-27 18:29:30 -04:00
parent aa8dac17d3
commit 3265812833
3 changed files with 14 additions and 13 deletions

View File

@ -33,14 +33,14 @@ class ShownoticeAction extends StreamAction {
} }
$profile = $notice->getProfile(); $profile = $notice->getProfile();
if (!$profile) { if (!$profile) {
$this->no_such_notice(); $this->no_such_notice();
} }
# Looks like we're good; show the header # Looks like we're good; show the header
common_show_header($profile->nickname."'s status on ".common_date_string($notice->created), common_show_header($profile->nickname."'s status on ".common_exact_date($notice->created),
NULL, $profile, NULL, $profile,
array($this, 'show_top')); array($this, 'show_top'));
@ -53,12 +53,12 @@ class ShownoticeAction extends StreamAction {
function show_top($user) { function show_top($user) {
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->id == $user->id) { if ($cur && $cur->id == $user->id) {
common_notice_form(); common_notice_form();
} }
} }
function no_such_notice() { function no_such_notice() {
common_user_error('No such notice.'); common_user_error('No such notice.');
} }

View File

@ -28,7 +28,7 @@ class StreamAction extends Action {
} }
function views_menu() { function views_menu() {
$user = NULL; $user = NULL;
$action = $this->trimmed('action'); $action = $this->trimmed('action');
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
@ -36,9 +36,9 @@ class StreamAction extends Action {
if ($nickname) { if ($nickname) {
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
} }
common_element_start('ul', array('id' => 'nav_views')); common_element_start('ul', array('id' => 'nav_views'));
common_menu_item(common_local_url('all', array('nickname' => common_menu_item(common_local_url('all', array('nickname' =>
$nickname)), $nickname)),
_t('Personal'), _t('Personal'),
@ -46,12 +46,12 @@ class StreamAction extends Action {
$action == 'all'); $action == 'all');
common_menu_item(common_local_url('showstream', array('nickname' => common_menu_item(common_local_url('showstream', array('nickname' =>
$nickname)), $nickname)),
_t('Profile'), _t('Profile'),
($user && $user->fullname) ? $user->fullname : $nickname, ($user && $user->fullname) ? $user->fullname : $nickname,
$action == 'showstream'); $action == 'showstream');
common_element_end('ul'); common_element_end('ul');
} }
function show_notice($notice) { function show_notice($notice) {
global $config; global $config;
$profile = $notice->getProfile(); $profile = $notice->getProfile();
@ -78,7 +78,8 @@ class StreamAction extends Action {
$noticeurl = common_local_url('shownotice', array('notice' => $notice->id)); $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
common_element_start('p', 'time'); common_element_start('p', 'time');
common_element('a', array('class' => 'notice', common_element('a', array('class' => 'notice',
'href' => $noticeurl), 'href' => $noticeurl,
'title' => common_exact_date($notice->created)),
common_date_string($notice->created)); common_date_string($notice->created));
common_element_end('p'); common_element_end('p');
common_element_end('li'); common_element_end('li');

View File

@ -731,7 +731,7 @@ function common_date_string($dt) {
$diff = $now - $t; $diff = $now - $t;
if ($now < $t) { # that shouldn't happen! if ($now < $t) { # that shouldn't happen!
return common_simple_date($dt); return common_exact_date($dt);
} else if ($diff < 60) { } else if ($diff < 60) {
return _t('a few seconds ago'); return _t('a few seconds ago');
} else if ($diff < 92) { } else if ($diff < 92) {
@ -753,11 +753,11 @@ function common_date_string($dt) {
} else if ($diff < 480 * 24 * 3600) { } else if ($diff < 480 * 24 * 3600) {
return _t('about a year ago'); return _t('about a year ago');
} else { } else {
return common_simple_date($dt); return common_exact_date($dt);
} }
} }
function common_simple_date($dt) { function common_exact_date($dt) {
$t = strtotime($dt); $t = strtotime($dt);
return date(DATE_RFC822, $t); return date(DATE_RFC822, $t);
} }