1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Make dates/times more concise in Diffusion

Summary: I think I like this better -- but maybe right-aligned?

Test Plan:
{F1180295}

{F1180296}

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D15495
This commit is contained in:
epriestley 2016-03-18 08:59:21 -07:00
parent f46686ff58
commit f07d0ae7c3
7 changed files with 43 additions and 9 deletions

View file

@ -103,7 +103,7 @@ final class DiffusionLastModifiedController extends DiffusionController {
$modified = DiffusionView::linkCommit(
$drequest->getRepository(),
$commit->getCommitIdentifier());
$date = phabricator_datetime($epoch, $viewer);
$date = $viewer->formatShortDateTime($epoch);
} else {
$modified = '';
$date = '';

View file

@ -39,7 +39,7 @@ final class DiffusionBranchTableView extends DiffusionView {
$commit = idx($commits, $branch->getCommitIdentifier());
if ($commit) {
$details = $commit->getSummary();
$datetime = phabricator_datetime($commit->getEpoch(), $viewer);
$datetime = $viewer->formatShortDateTime($commit->getEpoch());
$buildable = idx($buildables, $commit->getPHID());
if ($buildable) {
$build_status = $this->renderBuildable($buildable);
@ -147,7 +147,7 @@ final class DiffusionBranchTableView extends DiffusionView {
'',
'wide',
'',
'',
'right',
));
$view->setColumnVisibility(
array(

View file

@ -129,7 +129,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
'',
'',
'wide',
'',
'right',
));
$view->setColumnVisibility(
array(

View file

@ -95,7 +95,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
$epoch = $history->getEpoch();
if ($epoch) {
$committed = phabricator_datetime($epoch, $viewer);
$committed = $viewer->formatShortDateTime($epoch);
} else {
$committed = null;
}
@ -195,7 +195,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
'',
'',
'wide',
'',
'right',
));
$view->setColumnVisibility(
array(

View file

@ -88,7 +88,7 @@ final class DiffusionPushLogListView extends AphrontView {
// TODO: Make these human-readable.
$log->getChangeFlags(),
$log->getPushEvent()->getRejectCode(),
phabricator_datetime($log->getEpoch(), $viewer),
$viewer->formatShortDateTime($log->getEpoch()),
);
}
@ -119,7 +119,7 @@ final class DiffusionPushLogListView extends AphrontView {
'wide',
'n',
'n',
'date',
'right',
));
return $table;

View file

@ -28,6 +28,7 @@ final class DiffusionTagListView extends DiffusionView {
public function render() {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$viewer = $this->getViewer();
$buildables = $this->loadBuildables($this->commits);
$has_builds = false;
@ -100,7 +101,7 @@ final class DiffusionTagListView extends DiffusionView {
$build,
$author,
$description,
phabricator_datetime($tag->getEpoch(), $this->getViewer()),
$viewer->formatShortDateTime($tag->getEpoch()),
);
}
@ -123,6 +124,7 @@ final class DiffusionTagListView extends DiffusionView {
'',
'',
'wide',
'right',
))
->setColumnVisibility(
array(

View file

@ -742,6 +742,38 @@ final class PhabricatorUser
return new DateTimeZone($this->getTimezoneIdentifier());
}
public function formatShortDateTime($when, $now = null) {
if ($now === null) {
$now = PhabricatorTime::getNow();
}
try {
$when = new DateTime('@'.$when);
$now = new DateTime('@'.$now);
} catch (Exception $ex) {
return null;
}
$zone = $this->getTimeZone();
$when->setTimeZone($zone);
$now->setTimeZone($zone);
if ($when->format('Y') !== $now->format('Y')) {
// Different year, so show "Feb 31 2075".
$format = 'M j Y';
} else if ($when->format('Ymd') !== $now->format('Ymd')) {
// Same year but different month and day, so show "Feb 31".
$format = 'M j';
} else {
// Same year, month and day so show a time of day.
$pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT;
$format = $this->getPreference($pref_time);
}
return $when->format($format);
}
public function getPreference($key) {
$preferences = $this->loadPreferences();