当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorTime::parseLocalTime方法代码示例

本文整理汇总了PHP中PhabricatorTime::parseLocalTime方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorTime::parseLocalTime方法的具体用法?PHP PhabricatorTime::parseLocalTime怎么用?PHP PhabricatorTime::parseLocalTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorTime的用法示例。


在下文中一共展示了PhabricatorTime::parseLocalTime方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:29,代码来源:PhabricatorTimeTestCase.php

示例2: parseDateTime

 protected function parseDateTime($value)
 {
     if (!strlen($value)) {
         return null;
     }
     return PhabricatorTime::parseLocalTime($value, $this->getViewer());
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorSearchDateField.php

示例3: parseDateTime

 protected function parseDateTime($value)
 {
     if (!strlen($value)) {
         return null;
     }
     // If this appears to be an epoch timestamp, just return it unmodified.
     // This assumes values like "2016" or "20160101" are "Ymd".
     if (is_int($value) || ctype_digit($value)) {
         if ((int) $value > 30000000) {
             return (int) $value;
         }
     }
     return PhabricatorTime::parseLocalTime($value, $this->getViewer());
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:14,代码来源:PhabricatorSearchDateField.php

示例4: getStartDateTimeObjects

 private static function getStartDateTimeObjects(PhabricatorUser $user, $start_day_str)
 {
     $timezone = new DateTimeZone($user->getTimezoneIdentifier());
     $today_epoch = PhabricatorTime::parseLocalTime('today', $user);
     $today = new DateTime('@' . $today_epoch);
     $today->setTimeZone($timezone);
     if (strtolower($start_day_str) == 'today' || $today->format('l') == $start_day_str) {
         $start_day = clone $today;
     } else {
         $start_epoch = PhabricatorTime::parseLocalTime('last ' . $start_day_str, $user);
         $start_day = new DateTime('@' . $start_epoch);
         $start_day->setTimeZone($timezone);
     }
     return array('today' => $today, 'start_day' => $start_day);
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:15,代码来源:CalendarTimeUtil.php

示例5: getWindow

 public function getWindow($request)
 {
     $window_str = $request->getStr('window', '12 AM 7 days ago');
     $error = null;
     // Do locale-aware parsing so that the user's timezone is assumed for
     // time windows like "3 PM", rather than assuming the server timezone.
     $window_epoch = PhabricatorTime::parseLocalTime($window_str, $this->user);
     if ($window_epoch === null) {
         $error = 'Invalid';
         $window_epoch = time() - 60 * 60 * 24 * 7;
     }
     // If the time ends up in the future, convert it to the corresponding time
     // and equal distance in the past. This is so users can type "6 days" (which
     // means "6 days from now") and get the behavior of "6 days ago", rather
     // than no results (because the window epoch is in the future). This might
     // be a little confusing because it casues "tomorrow" to mean "yesterday"
     // and "2022" (or whatever) to mean "ten years ago", but these inputs are
     // nonsense anyway.
     if ($window_epoch > time()) {
         $window_epoch = time() - ($window_epoch - time());
     }
     return array($window_str, $window_epoch, $error);
 }
开发者ID:yangming85,项目名称:phabricator-extensions-Sprint,代码行数:23,代码来源:SprintView.php

示例6: parseDateTime

 /**
  * @task dates
  */
 protected function parseDateTime($date_time)
 {
     if (!strlen($date_time)) {
         return null;
     }
     return PhabricatorTime::parseLocalTime($date_time, $this->requireViewer());
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:10,代码来源:PhabricatorApplicationSearchEngine.php

示例7: applyApplicationSearchConstraintToQuery

 public function applyApplicationSearchConstraintToQuery(PhabricatorApplicationSearchEngine $engine, PhabricatorCursorPagedPolicyAwareQuery $query, $value)
 {
     $viewer = $this->getViewer();
     if (!is_array($value)) {
         $value = array();
     }
     $min_str = idx($value, 'min', '');
     if (strlen($min_str)) {
         $min = PhabricatorTime::parseLocalTime($min_str, $viewer);
     } else {
         $min = null;
     }
     $max_str = idx($value, 'max', '');
     if (strlen($max_str)) {
         $max = PhabricatorTime::parseLocalTime($max_str, $viewer);
     } else {
         $max = null;
     }
     if ($min !== null || $max !== null) {
         $query->withApplicationSearchRangeConstraint($this->newNumericIndex(null), $min, $max);
     }
 }
开发者ID:AceMood,项目名称:phabricator,代码行数:22,代码来源:PhabricatorStandardCustomFieldDate.php

示例8: getPagingParameters

 /**
  * From request parameters, figure out where we should jump to in the log.
  * We jump to either a date or log ID, but load a few lines of context before
  * it so the user can see the nearby conversation.
  */
 private function getPagingParameters(AphrontRequest $request, PhabricatorChatLogQuery $query)
 {
     $viewer = $request->getViewer();
     $at_id = $request->getInt('at');
     $at_date = $request->getStr('date');
     $context_log = null;
     $map = array();
     $query = clone $query;
     $query->setLimit(8);
     if ($at_id) {
         // Jump to the log in question, and load a few lines of context before
         // it.
         $context_logs = $query->setAfterID($at_id)->execute();
         $context_log = last($context_logs);
         $map = array($at_id => true);
     } else {
         if ($at_date) {
             $timestamp = PhabricatorTime::parseLocalTime($at_date, $viewer);
             if ($timestamp) {
                 $context_logs = $query->withMaximumEpoch($timestamp)->execute();
                 $context_log = last($context_logs);
                 $target_log = head($context_logs);
                 if ($target_log) {
                     $map = array($target_log->getID() => true);
                 }
             }
         }
     }
     if ($context_log) {
         $after = null;
         $before = $context_log->getID() - 1;
     } else {
         $after = $request->getInt('after');
         $before = $request->getInt('before');
     }
     return array($after, $before, $map);
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:42,代码来源:PhabricatorChatLogChannelLogController.php

示例9: newDateControl

 public function newDateControl($proxy, $time)
 {
     $control = id(new AphrontFormDateControl())->setLabel($proxy->getFieldName())->setName($proxy->getFieldKey())->setUser($proxy->getViewer())->setCaption($proxy->getCaption())->setAllowNull(!$proxy->getRequired())->setInitialTime($time);
     $value = $proxy->getFieldValue();
     if (!ctype_digit($value)) {
         $value = PhabricatorTime::parseLocalTime($value, $proxy->getViewer());
     }
     $control->setValue(nonempty($value, null));
     return $control;
 }
开发者ID:yangming85,项目名称:phabricator-extensions-Sprint,代码行数:10,代码来源:SprintProjectCustomField.php


注:本文中的PhabricatorTime::parseLocalTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。