本文整理汇总了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++;
}
}