mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
When printing timestamps on paper: use an absolute, context-free date format
Summary: Ref T13573. Using the browser "Print" feature on pages produces "Thu, Aug 4, 12:22" timestamps which require context to interpret precisely (they don't have a year and don't have a timezone). Instead, retain these timestamps in "screen" contexts but use "YYYY-MM-DD HH:MM:SS (UTC+X)" timestamps when printing. Test Plan: Printed Maniphest tasks and other pages in Safari and Chrome using "?__print__=1" and "Print to PDF", saw absolute timestamps after this chagne in the printed documents. Maniphest Tasks: T13573 Differential Revision: https://secure.phabricator.com/D21451
This commit is contained in:
parent
72f149bf39
commit
0854425d19
9 changed files with 87 additions and 7 deletions
|
@ -9,7 +9,7 @@ return array(
|
|||
'names' => array(
|
||||
'conpherence.pkg.css' => '0e3cf785',
|
||||
'conpherence.pkg.js' => '020aebcf',
|
||||
'core.pkg.css' => 'b13bef94',
|
||||
'core.pkg.css' => 'bd937962',
|
||||
'core.pkg.js' => 'adc34883',
|
||||
'dark-console.pkg.js' => '187792c2',
|
||||
'differential.pkg.css' => '5c459f92',
|
||||
|
@ -113,7 +113,7 @@ return array(
|
|||
'rsrc/css/application/slowvote/slowvote.css' => '1694baed',
|
||||
'rsrc/css/application/tokens/tokens.css' => 'ce5a50bd',
|
||||
'rsrc/css/application/uiexample/example.css' => 'b4795059',
|
||||
'rsrc/css/core/core.css' => '1b29ed61',
|
||||
'rsrc/css/core/core.css' => 'b3ebd90d',
|
||||
'rsrc/css/core/remarkup.css' => '94c3d777',
|
||||
'rsrc/css/core/syntax.css' => '548567f6',
|
||||
'rsrc/css/core/z-index.css' => 'ac3bfcd4',
|
||||
|
@ -779,7 +779,7 @@ return array(
|
|||
'phabricator-busy' => '5202e831',
|
||||
'phabricator-chatlog-css' => 'abdc76ee',
|
||||
'phabricator-content-source-view-css' => 'cdf0d579',
|
||||
'phabricator-core-css' => '1b29ed61',
|
||||
'phabricator-core-css' => 'b3ebd90d',
|
||||
'phabricator-countdown-css' => 'bff8012f',
|
||||
'phabricator-darklog' => '3b869402',
|
||||
'phabricator-darkmessage' => '26cd4b73',
|
||||
|
|
|
@ -5959,9 +5959,11 @@ phutil_register_library_map(array(
|
|||
'celerity_get_resource_uri' => 'applications/celerity/api.php',
|
||||
'hsprintf' => 'infrastructure/markup/render.php',
|
||||
'javelin_tag' => 'infrastructure/javelin/markup.php',
|
||||
'phabricator_absolute_datetime' => 'view/viewutils.php',
|
||||
'phabricator_date' => 'view/viewutils.php',
|
||||
'phabricator_datetime' => 'view/viewutils.php',
|
||||
'phabricator_datetimezone' => 'view/viewutils.php',
|
||||
'phabricator_dual_datetime' => 'view/viewutils.php',
|
||||
'phabricator_form' => 'infrastructure/javelin/markup.php',
|
||||
'phabricator_format_local_time' => 'view/viewutils.php',
|
||||
'phabricator_relative_date' => 'view/viewutils.php',
|
||||
|
|
|
@ -401,7 +401,7 @@ final class PhrictionDocumentController
|
|||
|
||||
$view->addProperty(
|
||||
pht('Last Edited'),
|
||||
phabricator_datetime($content->getDateCreated(), $viewer));
|
||||
phabricator_dual_datetime($content->getDateCreated(), $viewer));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,23 @@ function javelin_tag(
|
|||
unset($attributes['aural']);
|
||||
}
|
||||
|
||||
if (isset($attributes['print'])) {
|
||||
if ($attributes['print']) {
|
||||
$class = idx($attributes, 'class', '');
|
||||
$class = rtrim('print-only '.$class);
|
||||
$attributes['class'] = $class;
|
||||
|
||||
// NOTE: Alternative print content is hidden from screen readers.
|
||||
$attributes['aria-hidden'] = 'true';
|
||||
} else {
|
||||
$class = idx($attributes, 'class', '');
|
||||
$class = rtrim('screen-only '.$class);
|
||||
$attributes['class'] = $class;
|
||||
}
|
||||
unset($attributes['print']);
|
||||
}
|
||||
|
||||
|
||||
return phutil_tag($tag, $attributes, $content);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ final class PHUICurtainObjectRefView
|
|||
|
||||
$epoch = $this->epoch;
|
||||
if ($epoch !== null) {
|
||||
$epoch_view = phabricator_datetime($epoch, $viewer);
|
||||
$epoch_view = phabricator_dual_datetime($epoch, $viewer);
|
||||
|
||||
$epoch_cells = array();
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
}
|
||||
|
||||
public function setEpoch($epoch) {
|
||||
$date = phabricator_datetime($epoch, $this->getUser());
|
||||
$date = phabricator_dual_datetime($epoch, $this->getUser());
|
||||
$this->addIcon('none', $date);
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -591,7 +591,7 @@ final class PHUITimelineEventView extends AphrontView {
|
|||
}
|
||||
|
||||
if ($date_created) {
|
||||
$date = phabricator_datetime(
|
||||
$date = phabricator_dual_datetime(
|
||||
$date_created,
|
||||
$this->getUser());
|
||||
if ($this->anchor) {
|
||||
|
@ -611,6 +611,7 @@ final class PHUITimelineEventView extends AphrontView {
|
|||
$date),
|
||||
);
|
||||
}
|
||||
|
||||
$extra[] = $date;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,39 @@ function phabricator_time($epoch, $user) {
|
|||
$user->getUserSetting($time_key));
|
||||
}
|
||||
|
||||
function phabricator_dual_datetime($epoch, $user) {
|
||||
$screen_view = phabricator_datetime($epoch, $user);
|
||||
$print_view = phabricator_absolute_datetime($epoch, $user);
|
||||
|
||||
$screen_tag = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'print' => false,
|
||||
),
|
||||
$screen_view);
|
||||
|
||||
$print_tag = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'print' => true,
|
||||
),
|
||||
$print_view);
|
||||
|
||||
return array(
|
||||
$screen_tag,
|
||||
$print_tag,
|
||||
);
|
||||
}
|
||||
|
||||
function phabricator_absolute_datetime($epoch, $user) {
|
||||
$format = 'Y-m-d H:i:s (\\U\\T\\CP)';
|
||||
|
||||
$datetime = phabricator_format_local_time($epoch, $user, $format);
|
||||
$datetime = preg_replace('/(UTC[+-])0?([^:]+)(:00)?/', '\\1\\2', $datetime);
|
||||
|
||||
return $datetime;
|
||||
}
|
||||
|
||||
function phabricator_datetime($epoch, $user) {
|
||||
$time_key = PhabricatorTimeFormatSetting::SETTINGKEY;
|
||||
return phabricator_format_local_time(
|
||||
|
|
|
@ -162,6 +162,33 @@ hr {
|
|||
opacity: 0.25;
|
||||
}
|
||||
|
||||
.print-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* NOTE: These rules currently only work when applied to elements which
|
||||
actually want "display: inline". There is no "display: auto". If there
|
||||
is a future need to mix inline and block print elements, using
|
||||
"display: initial" may be a reasonable approach. */
|
||||
|
||||
.printable .print-only {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.printable .screen-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.screen-only {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.print-only {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
.routing-bar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
|
|
Loading…
Reference in a new issue