1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

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
This commit is contained in:
Bob Trahan 2011-12-03 16:36:19 -08:00
parent 9c1697383c
commit 588b959c03
9 changed files with 23 additions and 27 deletions

View file

@ -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',

View file

@ -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,
);

View file

@ -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);

View file

@ -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;
}

View file

@ -150,6 +150,8 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
),
'Recent Commits');
$viewer = $this->getRequest()->getUser();
$content =
'<div class="phabricator-profile-info-group">
<h1 class="phabricator-profile-info-header">Basic Information</h1>
@ -161,7 +163,9 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
</tr>
<tr>
<th>User Since</th>
<td>'.phabricator_format_timestamp($user->getDateCreated()).'</td>
<td>'.phabricator_datetime($user->getDateCreated(),
$viewer).
'</td>
</tr>
</table>
</div>

View file

@ -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';

View file

@ -157,8 +157,8 @@ class PhabricatorProjectProfileController
'<p><em>There are no projects attached for such specie.</em></p>';
}
$timestamp = phabricator_format_timestamp($project->getDateCreated());
$viewer = $this->getRequest()->getUser();
$timestamp = phabricator_datetime($project->getDateCreated(), $viewer);
$status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus());

View file

@ -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',

View file

@ -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,