本文整理汇总了PHP中PhabricatorUser::setTimezoneIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorUser::setTimezoneIdentifier方法的具体用法?PHP PhabricatorUser::setTimezoneIdentifier怎么用?PHP PhabricatorUser::setTimezoneIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorUser
的用法示例。
在下文中一共展示了PhabricatorUser::setTimezoneIdentifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParseLocalTime
public function testParseLocalTime()
{
$u = new PhabricatorUser();
$u->setTimezoneIdentifier('UTC');
$v = new PhabricatorUser();
$v->setTimezoneIdentifier('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->setTimezoneIdentifier('America/Los_Angeles');
$utc = new PhabricatorUser();
$utc->setTimezoneIdentifier('UTC');
$this->assertEqual('Jan 1 2000, 12:00 AM', phabricator_datetime(946684800, $utc), 'Datetime formatting');
$this->assertEqual('Jan 1 2000', phabricator_date(946684800, $utc), 'Date formatting');
$this->assertEqual('12:00 AM', phabricator_time(946684800, $utc), 'Time formatting');
$this->assertEqual('Dec 31 1999, 4:00 PM', phabricator_datetime(946684800, $user), 'Localization');
$this->assertEqual('', phabricator_datetime(0, $user), 'Missing epoch should fail gracefully');
}
示例3: testTimestampsStartDay
public function testTimestampsStartDay()
{
$u = new PhabricatorUser();
$u->setTimezoneIdentifier('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);
}