From 588b959c03ad99b44c49bece6b8c8ce1562b650c Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Sat, 3 Dec 2011 16:36:19 -0800 Subject: [PATCH] phabricator_format_timestamp => phabricator_datetime Summary: make the change, kill the function. be sure to get a good $user or $viewer variable Test Plan: for each controller or view, look at it in the ui. change timezone, refresh ui and note change. i did not test the OAuthSettingsPanelController; not sure how to get to that badboy and i got a bit lazy Maniphest Tasks: T222 Reviewers: epriestley Reviewed By: epriestley CC: aran, btrahan, epriestley Maniphest Tasks: T222 Differential Revision: 1166 --- src/__phutil_library_map__.php | 1 - .../PhabricatorCountdownListController.php | 2 +- .../DifferentialRevisionViewController.php | 1 + .../DifferentialRevisionUpdateHistoryView.php | 12 +++++++++++- .../PhabricatorPeopleProfileController.php | 6 +++++- ...icatorUserOAuthSettingsPanelController.php | 2 +- .../PhabricatorProjectProfileController.php | 4 ++-- .../PhabricatorRepositoryEditController.php | 3 ++- src/view/utils/viewutils.php | 19 ------------------- 9 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index cb0892e98b..13a9920002 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -736,7 +736,6 @@ phutil_register_library_map(array( 'phabricator_date' => 'view/utils', 'phabricator_datetime' => 'view/utils', 'phabricator_format_relative_time' => 'view/utils', - 'phabricator_format_timestamp' => 'view/utils', 'phabricator_format_units_generic' => 'view/utils', 'phabricator_render_form' => 'infrastructure/javelin/markup', 'phabricator_time' => 'view/utils', diff --git a/src/applications/countdown/controller/list/PhabricatorCountdownListController.php b/src/applications/countdown/controller/list/PhabricatorCountdownListController.php index ca52cf14c6..b9e6aa0ae8 100644 --- a/src/applications/countdown/controller/list/PhabricatorCountdownListController.php +++ b/src/applications/countdown/controller/list/PhabricatorCountdownListController.php @@ -70,7 +70,7 @@ class PhabricatorCountdownListController 'href' => '/countdown/'.$timer->getID().'/', ), phutil_escape_html($timer->getTitle())), - phabricator_format_timestamp($timer->getDatepoint()), + phabricator_datetime($timer->getDatepoint(), $user), $edit_button, $delete_button, ); diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index a11d39f0ce..3daa315afe 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -214,6 +214,7 @@ class DifferentialRevisionViewController extends DifferentialController { $diff_history->setSelectedVersusDiffID($diff_vs); $diff_history->setSelectedDiffID($target->getID()); $diff_history->setSelectedWhitespace($whitespace); + $diff_history->setUser($user); $local_view = new DifferentialLocalCommitsView(); $local_view->setUser($user); diff --git a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php index c2711f588a..4a99f86176 100644 --- a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php @@ -22,6 +22,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { private $selectedVersusDiffID; private $selectedDiffID; private $selectedWhitespace; + private $user; public function setDiffs($diffs) { $this->diffs = $diffs; @@ -43,6 +44,15 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { return $this; } + public function setUser($user) { + $this->user = $user; + return $this; + } + + public function getUser() { + return $this->user; + } + public function render() { require_celerity_resource('differential-core-view-css'); @@ -127,7 +137,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { $desc = $row['desc']; if ($row['age']) { - $age = phabricator_format_timestamp($row['age']); + $age = phabricator_datetime($row['age'], $this->getUser()); } else { $age = null; } diff --git a/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php b/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php index bf7f891940..71a50c61c1 100644 --- a/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php +++ b/src/applications/people/controller/profile/PhabricatorPeopleProfileController.php @@ -150,6 +150,8 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController { ), 'Recent Commits'); + $viewer = $this->getRequest()->getUser(); + $content = '

Basic Information

@@ -161,7 +163,9 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController { User Since - '.phabricator_format_timestamp($user->getDateCreated()).' + '.phabricator_datetime($user->getDateCreated(), + $viewer). + '
diff --git a/src/applications/people/controller/settings/panels/oauth/PhabricatorUserOAuthSettingsPanelController.php b/src/applications/people/controller/settings/panels/oauth/PhabricatorUserOAuthSettingsPanelController.php index 309500e82a..f5063dcc35 100644 --- a/src/applications/people/controller/settings/panels/oauth/PhabricatorUserOAuthSettingsPanelController.php +++ b/src/applications/people/controller/settings/panels/oauth/PhabricatorUserOAuthSettingsPanelController.php @@ -124,7 +124,7 @@ class PhabricatorUserOAuthSettingsPanelController if ($expires <= time()) { $expires = "Expired"; } else { - $expires = phabricator_format_timestamp($expires); + $expires = phabricator_datetime($expires, $user); } } else { $expires = 'No Information Available'; diff --git a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php index ed5ac31534..26d58687fe 100644 --- a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php @@ -157,8 +157,8 @@ class PhabricatorProjectProfileController '

There are no projects attached for such specie.

'; } - - $timestamp = phabricator_format_timestamp($project->getDateCreated()); + $viewer = $this->getRequest()->getUser(); + $timestamp = phabricator_datetime($project->getDateCreated(), $viewer); $status = PhabricatorProjectStatus::getNameForStatus( $project->getStatus()); diff --git a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php index 7f4adfb023..ec61a67bce 100644 --- a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php +++ b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php @@ -680,6 +680,7 @@ class PhabricatorRepositoryEditController $request = $this->getRequest(); $repository = $this->repository; $repository_id = $repository->getID(); + $viewer = $this->getRequest()->getUser(); $token = $repository->getDetail('github-token'); $path = '/github-post-receive/'.$repository_id.'/'.$token.'/'; @@ -716,7 +717,7 @@ class PhabricatorRepositoryEditController foreach ($notifications as $notification) { $rows[] = array( phutil_escape_html($notification->getRemoteAddress()), - phabricator_format_timestamp($notification->getDateCreated()), + phabricator_datetime($notification->getDateCreated(), $viewer), $notification->getPayload() ? phutil_escape_html(substr($notification->getPayload(), 0, 32).'...') : 'Empty', diff --git a/src/view/utils/viewutils.php b/src/view/utils/viewutils.php index 88ca5daf82..39fd706b6d 100644 --- a/src/view/utils/viewutils.php +++ b/src/view/utils/viewutils.php @@ -81,25 +81,6 @@ function phabricator_format_relative_time($duration) { $precision = 0); } -function phabricator_format_timestamp($epoch) { - $difference = (time() - $epoch); - - if ($difference < 0) { - $difference = -$difference; - $relative = 'from now'; - } else { - $relative = 'ago'; - } - - if ($difference < 60 * 60 * 24) { - return phabricator_format_relative_time($difference).' '.$relative; - } else if (date('Y') == date('Y', $epoch)) { - return date('M j, g:i A', $epoch); - } else { - return date('F jS, Y', $epoch); - } -} - function phabricator_format_units_generic( $n, array $scales,