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


PHP PhabricatorTime::pushTime方法代码示例

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


在下文中一共展示了PhabricatorTime::pushTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $viewer = $this->getViewer();
     $subscription_phid = $args->getArg('subscription');
     if (!$subscription_phid) {
         throw new PhutilArgumentUsageException(pht('Specify which subscription to invoice with %s.', '--subscription'));
     }
     $subscription = id(new PhortuneSubscriptionQuery())->setViewer($viewer)->withPHIDs(array($subscription_phid))->needTriggers(true)->executeOne();
     if (!$subscription) {
         throw new PhutilArgumentUsageException(pht('Unable to load subscription with PHID "%s".', $subscription_phid));
     }
     $now = $args->getArg('now');
     $now = $this->parseTimeArgument($now);
     if (!$now) {
         $now = PhabricatorTime::getNow();
     }
     $time_guard = PhabricatorTime::pushTime($now, date_default_timezone_get());
     $console->writeOut("%s\n", pht('Set current time to %s.', phabricator_datetime(PhabricatorTime::getNow(), $viewer)));
     $auto_range = $args->getArg('auto-range');
     $last_arg = $args->getArg('last');
     $next_arg = $args->getARg('next');
     if (!$auto_range && !$last_arg && !$next_arg) {
         throw new PhutilArgumentUsageException(pht('Specify a billing range with %s and %s, or use %s.', '--last', '--next', '--auto-range'));
     } else {
         if (!$auto_range & (!$last_arg || !$next_arg)) {
             throw new PhutilArgumentUsageException(pht('When specifying %s or %s, you must specify both arguments ' . 'to define the beginning and end of the billing range.', '--last', '--next'));
         } else {
             if (!$auto_range && ($last_arg && $next_arg)) {
                 $last_time = $this->parseTimeArgument($args->getArg('last'));
                 $next_time = $this->parseTimeArgument($args->getArg('next'));
             } else {
                 if ($auto_range && ($last_arg || $next_arg)) {
                     throw new PhutilArgumentUsageException(pht('Use either %s or %s and %s to specify the ' . 'billing range, but not both.', '--auto-range', '--last', '--next'));
                 } else {
                     $trigger = $subscription->getTrigger();
                     $event = $trigger->getEvent();
                     if (!$event) {
                         throw new PhutilArgumentUsageException(pht('Unable to calculate %s, this subscription has not been ' . 'scheduled for billing yet. Wait for the trigger daemon to ' . 'schedule the subscription.', '--auto-range'));
                     }
                     $last_time = $event->getLastEventEpoch();
                     $next_time = $event->getNextEventEpoch();
                 }
             }
         }
     }
     $console->writeOut("%s\n", pht('Preparing to invoice subscription "%s" from %s to %s.', $subscription->getSubscriptionName(), $last_time ? phabricator_datetime($last_time, $viewer) : pht('subscription creation'), phabricator_datetime($next_time, $viewer)));
     PhabricatorWorker::setRunAllTasksInProcess(true);
     if (!$args->getArg('force')) {
         $console->writeOut("**<bg:yellow> %s </bg>**\n%s\n", pht('WARNING'), phutil_console_wrap(pht('Manually invoicing will double bill payment accounts if the ' . 'range overlaps an existing or future invoice. This script is ' . 'intended for testing and development, and should not be part ' . 'of routine billing operations. If you continue, you may ' . 'incorrectly overcharge customers.')));
         if (!phutil_console_confirm(pht('Really invoice this subscription?'))) {
             throw new Exception(pht('Declining to invoice.'));
         }
     }
     PhabricatorWorker::scheduleTask('PhortuneSubscriptionWorker', array('subscriptionPHID' => $subscription->getPHID(), 'trigger.last-epoch' => $last_time, 'trigger.this-epoch' => $next_time, 'manual' => true), array('objectPHID' => $subscription->getPHID()));
     return 0;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:57,代码来源:PhabricatorPhortuneManagementInvoiceWorkflow.php

示例3: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $viewer = $this->getViewer();
     $triggers = $this->loadTriggers($args);
     $now = $args->getArg('now');
     $now = $this->parseTimeArgument($now);
     if (!$now) {
         $now = PhabricatorTime::getNow();
     }
     $time_guard = PhabricatorTime::pushTime($now, date_default_timezone_get());
     $console->writeOut("%s\n", pht('Set current time to %s.', phabricator_datetime(PhabricatorTime::getNow(), $viewer)));
     $last_time = $this->parseTimeArgument($args->getArg('last'));
     $next_time = $this->parseTimeArgument($args->getArg('next'));
     PhabricatorWorker::setRunAllTasksInProcess(true);
     foreach ($triggers as $trigger) {
         $console->writeOut("%s\n", pht('Executing trigger %s.', $this->describeTrigger($trigger)));
         $event = $trigger->getEvent();
         if ($event) {
             if (!$last_time) {
                 $last_time = $event->getLastEventEpoch();
             }
             if (!$next_time) {
                 $next_time = $event->getNextEventEpoch();
             }
         }
         if (!$next_time) {
             $console->writeOut("%s\n", pht('Trigger is not scheduled to execute. Use --next to simluate ' . 'a scheduled event.'));
             continue;
         } else {
             $console->writeOut("%s\n", pht('Executing event as though it was scheduled to execute at %s.', phabricator_datetime($next_time, $viewer)));
         }
         if (!$last_time) {
             $console->writeOut("%s\n", pht('Executing event as though it never previously executed.'));
         } else {
             $console->writeOut("%s\n", pht('Executing event as though it previously executed at %s.', phabricator_datetime($last_time, $viewer)));
         }
         $trigger->executeTrigger($last_time, $next_time);
         $reschedule_time = $trigger->getNextEventEpoch($next_time, $is_reschedule = true);
         if (!$reschedule_time) {
             $console->writeOut("%s\n", pht('After executing under these conditions, this event would never ' . 'execute again.'));
         } else {
             $console->writeOut("%s\n", pht('After executing under these conditions, this event would ' . 'next execute at %s.', phabricator_datetime($reschedule_time, $viewer)));
         }
     }
     return 0;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:47,代码来源:PhabricatorWorkerTriggerManagementFireWorkflow.php

示例4: testCustomPolicyRuleLunarPhase

 public function testCustomPolicyRuleLunarPhase()
 {
     $user_a = $this->generateNewTestUser();
     $author = $this->generateNewTestUser();
     $policy = id(new PhabricatorPolicy())->setRules(array(array('action' => PhabricatorPolicy::ACTION_ALLOW, 'rule' => 'PhabricatorLunarPhasePolicyRule', 'value' => 'new')))->save();
     $task = ManiphestTask::initializeNewTask($author);
     $task->setViewPolicy($policy->getPHID());
     $task->save();
     $time_a = PhabricatorTime::pushTime(934354800, 'UTC');
     $can_a_view = PhabricatorPolicyFilter::hasCapability($user_a, $task, PhabricatorPolicyCapability::CAN_VIEW);
     $this->assertTrue($can_a_view);
     unset($time_a);
     $time_b = PhabricatorTime::pushTime(1116745200, 'UTC');
     $can_a_view = PhabricatorPolicyFilter::hasCapability($user_a, $task, PhabricatorPolicyCapability::CAN_VIEW);
     $this->assertFalse($can_a_view);
     unset($time_b);
 }
开发者ID:truSense,项目名称:phabricator,代码行数:17,代码来源:PhabricatorPolicyDataTestCase.php

示例5: 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);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:18,代码来源:CalendarTimeUtilTestCase.php


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