From b0234802778503934ab1827aa358bb2b3d36fbc4 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 21 Mar 2012 15:04:49 -0700 Subject: [PATCH] Display day of week in dates Summary: I've found it quite useful to know day of week of most displayed dates. This is useful in periodic workflows (e.g. cut on Sunday, push on Tuesday). It adds the day only to recent dates to save some space (similar approach as `ls -l`). Test Plan: / Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T1034 Differential Revision: https://secure.phabricator.com/D1984 --- src/view/utils/viewutils.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/view/utils/viewutils.php b/src/view/utils/viewutils.php index 16d5fac521..9fa8f534c6 100644 --- a/src/view/utils/viewutils.php +++ b/src/view/utils/viewutils.php @@ -20,7 +20,7 @@ function phabricator_date($epoch, $user) { return __phabricator_format_local_time( $epoch, $user, - 'M j Y'); + __phabricator_date_format($epoch)); } function phabricator_on_relative_date($epoch, $user) { @@ -61,7 +61,16 @@ function phabricator_datetime($epoch, $user) { return __phabricator_format_local_time( $epoch, $user, - 'M j Y, g:i A'); + __phabricator_date_format($epoch).', g:i A'); +} + +function __phabricator_date_format($epoch) { + $format = 'M j Y'; + $now = time(); + if ($epoch <= $now && $epoch > $now - 30 * 24 * 60 * 60) { + $format = 'D, M j'; + } + return $format; } /**