@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+87 -7
+3 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '0e3cf785', 11 11 'conpherence.pkg.js' => '020aebcf', 12 - 'core.pkg.css' => 'b13bef94', 12 + 'core.pkg.css' => 'bd937962', 13 13 'core.pkg.js' => 'adc34883', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => '5c459f92', ··· 113 113 'rsrc/css/application/slowvote/slowvote.css' => '1694baed', 114 114 'rsrc/css/application/tokens/tokens.css' => 'ce5a50bd', 115 115 'rsrc/css/application/uiexample/example.css' => 'b4795059', 116 - 'rsrc/css/core/core.css' => '1b29ed61', 116 + 'rsrc/css/core/core.css' => 'b3ebd90d', 117 117 'rsrc/css/core/remarkup.css' => '94c3d777', 118 118 'rsrc/css/core/syntax.css' => '548567f6', 119 119 'rsrc/css/core/z-index.css' => 'ac3bfcd4', ··· 779 779 'phabricator-busy' => '5202e831', 780 780 'phabricator-chatlog-css' => 'abdc76ee', 781 781 'phabricator-content-source-view-css' => 'cdf0d579', 782 - 'phabricator-core-css' => '1b29ed61', 782 + 'phabricator-core-css' => 'b3ebd90d', 783 783 'phabricator-countdown-css' => 'bff8012f', 784 784 'phabricator-darklog' => '3b869402', 785 785 'phabricator-darkmessage' => '26cd4b73',
+2
src/__phutil_library_map__.php
··· 5959 5959 'celerity_get_resource_uri' => 'applications/celerity/api.php', 5960 5960 'hsprintf' => 'infrastructure/markup/render.php', 5961 5961 'javelin_tag' => 'infrastructure/javelin/markup.php', 5962 + 'phabricator_absolute_datetime' => 'view/viewutils.php', 5962 5963 'phabricator_date' => 'view/viewutils.php', 5963 5964 'phabricator_datetime' => 'view/viewutils.php', 5964 5965 'phabricator_datetimezone' => 'view/viewutils.php', 5966 + 'phabricator_dual_datetime' => 'view/viewutils.php', 5965 5967 'phabricator_form' => 'infrastructure/javelin/markup.php', 5966 5968 'phabricator_format_local_time' => 'view/viewutils.php', 5967 5969 'phabricator_relative_date' => 'view/viewutils.php',
+1 -1
src/applications/phriction/controller/PhrictionDocumentController.php
··· 401 401 402 402 $view->addProperty( 403 403 pht('Last Edited'), 404 - phabricator_datetime($content->getDateCreated(), $viewer)); 404 + phabricator_dual_datetime($content->getDateCreated(), $viewer)); 405 405 406 406 return $view; 407 407 }
+17
src/infrastructure/javelin/markup.php
··· 50 50 unset($attributes['aural']); 51 51 } 52 52 53 + if (isset($attributes['print'])) { 54 + if ($attributes['print']) { 55 + $class = idx($attributes, 'class', ''); 56 + $class = rtrim('print-only '.$class); 57 + $attributes['class'] = $class; 58 + 59 + // NOTE: Alternative print content is hidden from screen readers. 60 + $attributes['aria-hidden'] = 'true'; 61 + } else { 62 + $class = idx($attributes, 'class', ''); 63 + $class = rtrim('screen-only '.$class); 64 + $attributes['class'] = $class; 65 + } 66 + unset($attributes['print']); 67 + } 68 + 69 + 53 70 return phutil_tag($tag, $attributes, $content); 54 71 } 55 72
+1 -1
src/view/phui/PHUICurtainObjectRefView.php
··· 46 46 47 47 $epoch = $this->epoch; 48 48 if ($epoch !== null) { 49 - $epoch_view = phabricator_datetime($epoch, $viewer); 49 + $epoch_view = phabricator_dual_datetime($epoch, $viewer); 50 50 51 51 $epoch_cells = array(); 52 52
+1 -1
src/view/phui/PHUIObjectItemView.php
··· 192 192 } 193 193 194 194 public function setEpoch($epoch) { 195 - $date = phabricator_datetime($epoch, $this->getUser()); 195 + $date = phabricator_dual_datetime($epoch, $this->getUser()); 196 196 $this->addIcon('none', $date); 197 197 return $this; 198 198 }
+2 -1
src/view/phui/PHUITimelineEventView.php
··· 591 591 } 592 592 593 593 if ($date_created) { 594 - $date = phabricator_datetime( 594 + $date = phabricator_dual_datetime( 595 595 $date_created, 596 596 $this->getUser()); 597 597 if ($this->anchor) { ··· 611 611 $date), 612 612 ); 613 613 } 614 + 614 615 $extra[] = $date; 615 616 } 616 617
+33
src/view/viewutils.php
··· 38 38 $user->getUserSetting($time_key)); 39 39 } 40 40 41 + function phabricator_dual_datetime($epoch, $user) { 42 + $screen_view = phabricator_datetime($epoch, $user); 43 + $print_view = phabricator_absolute_datetime($epoch, $user); 44 + 45 + $screen_tag = javelin_tag( 46 + 'span', 47 + array( 48 + 'print' => false, 49 + ), 50 + $screen_view); 51 + 52 + $print_tag = javelin_tag( 53 + 'span', 54 + array( 55 + 'print' => true, 56 + ), 57 + $print_view); 58 + 59 + return array( 60 + $screen_tag, 61 + $print_tag, 62 + ); 63 + } 64 + 65 + function phabricator_absolute_datetime($epoch, $user) { 66 + $format = 'Y-m-d H:i:s (\\U\\T\\CP)'; 67 + 68 + $datetime = phabricator_format_local_time($epoch, $user, $format); 69 + $datetime = preg_replace('/(UTC[+-])0?([^:]+)(:00)?/', '\\1\\2', $datetime); 70 + 71 + return $datetime; 72 + } 73 + 41 74 function phabricator_datetime($epoch, $user) { 42 75 $time_key = PhabricatorTimeFormatSetting::SETTINGKEY; 43 76 return phabricator_format_local_time(
+27
webroot/rsrc/css/core/core.css
··· 162 162 opacity: 0.25; 163 163 } 164 164 165 + .print-only { 166 + display: none; 167 + } 168 + 169 + /* NOTE: These rules currently only work when applied to elements which 170 + actually want "display: inline". There is no "display: auto". If there 171 + is a future need to mix inline and block print elements, using 172 + "display: initial" may be a reasonable approach. */ 173 + 174 + .printable .print-only { 175 + display: inline; 176 + } 177 + 178 + .printable .screen-only { 179 + display: none; 180 + } 181 + 182 + @media print { 183 + .screen-only { 184 + display: none; 185 + } 186 + 187 + .print-only { 188 + display: inline; 189 + } 190 + } 191 + 165 192 .routing-bar { 166 193 position: fixed; 167 194 top: 0;