本文整理汇总了PHP中PhabricatorUser::overrideTimezoneIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::overrideTimezoneIdentifier方法的具体用法?PHP PhabricatorUser::overrideTimezoneIdentifier怎么用?PHP PhabricatorUser::overrideTimezoneIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorUser
的用法示例。
在下文中一共展示了PhabricatorUser::overrideTimezoneIdentifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParseLocalTime
public function testParseLocalTime()
{
$u = new PhabricatorUser();
$u->overrideTimezoneIdentifier('UTC');
$v = new PhabricatorUser();
$v->overrideTimezoneIdentifier('America/Los_Angeles');
$t = 1370202281;
// 2013-06-02 12:44:41 -0700
$time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
$this->assertEqual($t, PhabricatorTime::parseLocalTime('now', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('now', $v));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $v));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $v));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 19:44:41', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41', $v));
$this->assertEqual($t + 3600, PhabricatorTime::parseLocalTime('+1 hour', $u));
$this->assertEqual($t + 3600, PhabricatorTime::parseLocalTime('+1 hour', $v));
unset($time);
$t = 1370239200;
// 2013-06-02 23:00:00 -0700
$time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
// For the UTC user, midnight was 6 hours ago because it's early in the
// morning for htem. For the PDT user, midnight was 23 hours ago.
$this->assertEqual($t + -6 * 3600 + 60, PhabricatorTime::parseLocalTime('12:01:00 AM', $u));
$this->assertEqual($t + -23 * 3600 + 60, PhabricatorTime::parseLocalTime('12:01:00 AM', $v));
unset($time);
}
示例2: testLocalTimeFormatting
public function testLocalTimeFormatting()
{
$user = new PhabricatorUser();
$user->overrideTimezoneIdentifier('America/Los_Angeles');
$utc = new PhabricatorUser();
$utc->overrideTimezoneIdentifier('UTC');
$this->assertEqual('Jan 1 2000, 12:00 AM', phabricator_datetime(946684800, $utc), pht('Datetime formatting'));
$this->assertEqual('Jan 1 2000', phabricator_date(946684800, $utc), pht('Date formatting'));
$this->assertEqual('12:00 AM', phabricator_time(946684800, $utc), pht('Time formatting'));
$this->assertEqual('Dec 31 1999, 4:00 PM', phabricator_datetime(946684800, $user), pht('Localization'));
$this->assertEqual('', phabricator_datetime(0, $user), pht('Missing epoch should fail gracefully'));
}
示例3: testTimestampsStartDay
public function testTimestampsStartDay()
{
$u = new PhabricatorUser();
$u->overrideTimezoneIdentifier('America/Los_Angeles');
$days = $this->getAllDays();
foreach ($days as $day) {
$data = CalendarTimeUtil::getTimestamps($u, $day, 1);
$this->assertEqual($day, $data['epoch_stamps'][0]->format('l'));
}
$t = 1370202281;
// 2013-06-02 12:44:41 -0700 -- a Sunday
$time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
foreach ($days as $day) {
$data = CalendarTimeUtil::getTimestamps($u, $day, 1);
$this->assertEqual($day, $data['epoch_stamps'][0]->format('l'));
}
unset($time);
}