@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<?php
2
3final class PhabricatorLocalTimeTestCase extends PhabricatorTestCase {
4
5 protected function getPhabricatorTestCaseConfiguration() {
6 return array(
7 self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
8 );
9 }
10
11 public function testLocalTimeFormatting() {
12 $user = $this->generateNewTestUser();
13 $user->overrideTimezoneIdentifier('America/Los_Angeles');
14
15 $utc = $this->generateNewTestUser();
16 $utc->overrideTimezoneIdentifier('UTC');
17
18 $this->assertEqual(
19 'Jan 1 2000, 12:00 AM',
20 phabricator_datetime(946684800, $utc),
21 pht('Datetime formatting'));
22 $this->assertEqual(
23 'Jan 1 2000',
24 phabricator_date(946684800, $utc),
25 pht('Date formatting'));
26 $this->assertEqual(
27 '12:00 AM',
28 phabricator_time(946684800, $utc),
29 pht('Time formatting'));
30
31 $this->assertEqual(
32 'Dec 31 1999, 4:00 PM',
33 phabricator_datetime(946684800, $user),
34 pht('Localization'));
35
36 $this->assertEqual(
37 '',
38 phabricator_datetime(0, $user),
39 pht('Missing epoch should fail gracefully'));
40 }
41
42}