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:
parent
f46686ff58
commit
f07d0ae7c3
|
@ -103,7 +103,7 @@ final class DiffusionLastModifiedController extends DiffusionController {
|
||||||
$modified = DiffusionView::linkCommit(
|
$modified = DiffusionView::linkCommit(
|
||||||
$drequest->getRepository(),
|
$drequest->getRepository(),
|
||||||
$commit->getCommitIdentifier());
|
$commit->getCommitIdentifier());
|
||||||
$date = phabricator_datetime($epoch, $viewer);
|
$date = $viewer->formatShortDateTime($epoch);
|
||||||
} else {
|
} else {
|
||||||
$modified = '';
|
$modified = '';
|
||||||
$date = '';
|
$date = '';
|
||||||
|
|
|
@ -39,7 +39,7 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
$commit = idx($commits, $branch->getCommitIdentifier());
|
$commit = idx($commits, $branch->getCommitIdentifier());
|
||||||
if ($commit) {
|
if ($commit) {
|
||||||
$details = $commit->getSummary();
|
$details = $commit->getSummary();
|
||||||
$datetime = phabricator_datetime($commit->getEpoch(), $viewer);
|
$datetime = $viewer->formatShortDateTime($commit->getEpoch());
|
||||||
$buildable = idx($buildables, $commit->getPHID());
|
$buildable = idx($buildables, $commit->getPHID());
|
||||||
if ($buildable) {
|
if ($buildable) {
|
||||||
$build_status = $this->renderBuildable($buildable);
|
$build_status = $this->renderBuildable($buildable);
|
||||||
|
@ -147,7 +147,7 @@ final class DiffusionBranchTableView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'wide',
|
'wide',
|
||||||
'',
|
'',
|
||||||
'',
|
'right',
|
||||||
));
|
));
|
||||||
$view->setColumnVisibility(
|
$view->setColumnVisibility(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -129,7 +129,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'wide',
|
'wide',
|
||||||
'',
|
'right',
|
||||||
));
|
));
|
||||||
$view->setColumnVisibility(
|
$view->setColumnVisibility(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -95,7 +95,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
$epoch = $history->getEpoch();
|
$epoch = $history->getEpoch();
|
||||||
|
|
||||||
if ($epoch) {
|
if ($epoch) {
|
||||||
$committed = phabricator_datetime($epoch, $viewer);
|
$committed = $viewer->formatShortDateTime($epoch);
|
||||||
} else {
|
} else {
|
||||||
$committed = null;
|
$committed = null;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'wide',
|
'wide',
|
||||||
'',
|
'right',
|
||||||
));
|
));
|
||||||
$view->setColumnVisibility(
|
$view->setColumnVisibility(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -88,7 +88,7 @@ final class DiffusionPushLogListView extends AphrontView {
|
||||||
// TODO: Make these human-readable.
|
// TODO: Make these human-readable.
|
||||||
$log->getChangeFlags(),
|
$log->getChangeFlags(),
|
||||||
$log->getPushEvent()->getRejectCode(),
|
$log->getPushEvent()->getRejectCode(),
|
||||||
phabricator_datetime($log->getEpoch(), $viewer),
|
$viewer->formatShortDateTime($log->getEpoch()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ final class DiffusionPushLogListView extends AphrontView {
|
||||||
'wide',
|
'wide',
|
||||||
'n',
|
'n',
|
||||||
'n',
|
'n',
|
||||||
'date',
|
'right',
|
||||||
));
|
));
|
||||||
|
|
||||||
return $table;
|
return $table;
|
||||||
|
|
|
@ -28,6 +28,7 @@ final class DiffusionTagListView extends DiffusionView {
|
||||||
public function render() {
|
public function render() {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$buildables = $this->loadBuildables($this->commits);
|
$buildables = $this->loadBuildables($this->commits);
|
||||||
$has_builds = false;
|
$has_builds = false;
|
||||||
|
@ -100,7 +101,7 @@ final class DiffusionTagListView extends DiffusionView {
|
||||||
$build,
|
$build,
|
||||||
$author,
|
$author,
|
||||||
$description,
|
$description,
|
||||||
phabricator_datetime($tag->getEpoch(), $this->getViewer()),
|
$viewer->formatShortDateTime($tag->getEpoch()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ final class DiffusionTagListView extends DiffusionView {
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
'wide',
|
'wide',
|
||||||
|
'right',
|
||||||
))
|
))
|
||||||
->setColumnVisibility(
|
->setColumnVisibility(
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -742,6 +742,38 @@ final class PhabricatorUser
|
||||||
return new DateTimeZone($this->getTimezoneIdentifier());
|
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) {
|
public function getPreference($key) {
|
||||||
$preferences = $this->loadPreferences();
|
$preferences = $this->loadPreferences();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue