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


PHP CTimeZone::makeUtc方法代码示例

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


在下文中一共展示了CTimeZone::makeUtc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testStandardOffsetSeconds

 public function testStandardOffsetSeconds()
 {
     $timeZone = CTimeZone::makeUtc();
     $this->assertTrue($timeZone->standardOffsetSeconds() == 0 * 3600);
     $timeZone = new CTimeZone("Europe/Helsinki");
     $this->assertTrue($timeZone->standardOffsetSeconds() == 2 * 3600);
     $timeZone = new CTimeZone("America/Los_Angeles");
     $this->assertTrue($timeZone->standardOffsetSeconds() == -8 * 3600);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:9,代码来源:CTimeZoneTest.php

示例2: initializeFramework

 /**
  * @ignore
  */
 public static function initializeFramework()
 {
     $currEnv;
     if (!$GLOBALS["PHRED_TESTS"]) {
         // Try to get the name of the environment in which the application is currently running without the risk of
         // encountering an error or triggering an assertion, which could otherwise reveal sensitive debugging
         // information if "display_errors" happens to be enabled in php.ini.
         $appConfigFp = $GLOBALS["PHRED_PATH_TO_APP"] . "/Configuration" . "/Application.json";
         if (file_exists($appConfigFp)) {
             $appConfig = file_get_contents($appConfigFp);
             if (is_string($appConfig)) {
                 $matches;
                 $res = preg_match("/^\\h*\"environment\"\\s*:\\s*\"(\\w+)\"/m", $appConfig, $matches);
                 if ($res === 1) {
                     $currEnv = $matches[1];
                 }
             }
         }
     } else {
         $currEnv = "tst";
     }
     if (isset($currEnv)) {
         // Based on the current environment, set some debugging options to temporary values for the time while the
         // configuration is not yet read.
         if (strcasecmp($currEnv, "dev") == 0) {
             // Development.
             ini_set("display_errors", "On");
             CDebug::setAssertionsLevel1(true);
             CDebug::setAssertionsLevel2(false);
         } else {
             if (strcasecmp($currEnv, "pro") == 0) {
                 // Production.
                 ini_set("display_errors", "Off");
                 CDebug::setAssertionsLevel1(false);
                 CDebug::setAssertionsLevel2(false);
             } else {
                 if (strcasecmp($currEnv, "tst") == 0) {
                     // Testing.
                     ini_set("display_errors", "On");
                     CDebug::setAssertionsLevel1(true);
                     CDebug::setAssertionsLevel2(true);
                 } else {
                     // Unknown environment.
                     error_reporting(E_ALL);
                     ini_set("display_errors", "On");
                 }
             }
         }
     } else {
         error_reporting(E_ALL);
         ini_set("display_errors", "On");
         trigger_error("Could not read the name of the current environment.", E_USER_ERROR);
     }
     // Read all the configuration options.
     CConfiguration::initialize();
     // Set whether error messages should be shown is the output.
     if (CConfiguration::option("debug.displayErrors")) {
         ini_set("display_errors", "On");
     } else {
         ini_set("display_errors", "Off");
     }
     // Set the error reporting level.
     $errorReportingLevel = constant(CConfiguration::option("debug.errorReportingLevel"));
     error_reporting($errorReportingLevel);
     // Process the configuration options that are related to debugging.
     $debug = CConfiguration::option("debug");
     // Assertions and the conditions on which they get active.
     $assertionsAreActive = false;
     $assertionsAreEnabled = $debug["enableAssertions"];
     if ($assertionsAreEnabled) {
         $assertionsAreActiveBasedOn = $debug["assertionsAreActiveBasedOn"];
         if (CString::equalsCi($assertionsAreActiveBasedOn, "always")) {
             // Always.
             $assertionsAreActive = true;
         } else {
             // Reference time zone.
             $refTimeZone;
             $timeZoneName = $debug["referenceTimeZone"];
             if (!CString::isEmpty($timeZoneName)) {
                 $refTimeZone = new CTimeZone($timeZoneName);
             } else {
                 $refTimeZone = CTimeZone::makeUtc();
             }
             if (CString::equalsCi($assertionsAreActiveBasedOn, "hour")) {
                 // Current time.
                 $currTime = CTime::now();
                 // Hour.
                 $hourRanges = $debug["assertionsAreActiveWithinHourRange"];
                 $currHour = $currTime->hourInTimeZone($refTimeZone);
                 if (!is_carray($hourRanges[0])) {
                     $hourRanges = CArray::fromElements($hourRanges);
                 }
                 $len = CArray::length($hourRanges);
                 for ($i = 0; $i < $len; $i++) {
                     $range = $hourRanges[$i];
                     assert('is_int($range[0]) && is_int($range[1])', vs(isset($this), get_defined_vars()));
                     if ($range[0] <= $currHour && $currHour <= $range[1]) {
//.........这里部分代码省略.........
开发者ID:nunodotferreira,项目名称:Phred,代码行数:101,代码来源:CSystem.php


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