本文整理匯總了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);
}