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


PHP Uuid::timeOfDayTest方法代码示例

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


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

示例1: test32BitMatch64BitForOneHourPeriod

 /**
  * Iterates over a 3600-second period and tests to ensure that, for each
  * second in the period, the 32-bit and 64-bit versions of the UUID match
  */
 public function test32BitMatch64BitForOneHourPeriod()
 {
     $this->skipIfNoMoontoastMath();
     $this->skip64BitTest();
     $currentTime = strtotime('2012-12-11T00:00:00+00:00');
     $endTime = $currentTime + 3600;
     while ($currentTime <= $endTime) {
         foreach (array(0, 50000, 250000, 500000, 750000, 999999) as $usec) {
             $timeOfDay = array('sec' => $currentTime, 'usec' => $usec, 'minuteswest' => 0, 'dsttime' => 0);
             Uuid::$timeOfDayTest = $timeOfDay;
             Uuid::$force32Bit = true;
             $uuid32 = Uuid::uuid1(0x7ffffffe, 0x1669);
             Uuid::$force32Bit = false;
             $uuid64 = Uuid::uuid1(0x7ffffffe, 0x1669);
             $this->assertTrue($uuid32->equals($uuid64), 'Breaks at ' . gmdate('r', $currentTime) . "; 32-bit: {$uuid32->toString()}, 64-bit: {$uuid64->toString()}");
             // Assert that the time matches
             $testTime = round($currentTime + $usec / 1000000);
             $this->assertEquals($testTime, $uuid64->getDateTime()->getTimestamp());
             $this->assertEquals($testTime, $uuid32->getDateTime()->getTimestamp());
         }
         $currentTime++;
     }
 }
开发者ID:joemar-tagpuno,项目名称:uuid,代码行数:27,代码来源:UuidTest.php


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