1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Mark date and time format translatable

Summary:
This allows translations to specify custom date and time format.
We will need to call `setlocale()` or build system independent on it at some point but I guess it is good for now.

Test Plan: Translated 'D, M j, g:i A', saw it in diff.

Reviewers: btrahan, epriestley

Reviewed By: btrahan

CC: aran, Korvin

Maniphest Tasks: T1139, T1321

Differential Revision: https://secure.phabricator.com/D2809
This commit is contained in:
vrana 2012-06-20 12:33:09 -07:00
parent a7a978d1f3
commit e3eb8d55c5

View file

@ -54,21 +54,21 @@ function phabricator_time($epoch, $user) {
return phabricator_format_local_time( return phabricator_format_local_time(
$epoch, $epoch,
$user, $user,
'g:i A'); pht('g:i A'));
} }
function phabricator_datetime($epoch, $user) { function phabricator_datetime($epoch, $user) {
return phabricator_format_local_time( return phabricator_format_local_time(
$epoch, $epoch,
$user, $user,
_phabricator_date_format($epoch).', g:i A'); pht('%s, g:i A', _phabricator_date_format($epoch)));
} }
function _phabricator_date_format($epoch) { function _phabricator_date_format($epoch) {
$format = 'M j Y'; $format = pht('M j Y');
$now = time(); $now = time();
if ($epoch <= $now && $epoch > $now - 30 * 24 * 60 * 60) { if ($epoch <= $now && $epoch > $now - 30 * 24 * 60 * 60) {
$format = 'D, M j'; $format = pht('D, M j');
} }
return $format; return $format;
} }
@ -115,7 +115,7 @@ function phabricator_format_local_time($epoch, $user, $format) {
$date->setTimeZone($zone); $date->setTimeZone($zone);
return $date->format($format); return PhutilTranslator::getInstance()->translateDate($format, $date);
} }
function phabricator_format_relative_time($duration) { function phabricator_format_relative_time($duration) {