test(compare): trace deterministic monthly seed progression
This commit is contained in:
+22
-1
@@ -7,6 +7,19 @@ use phpDocumentor\Reflection\Types\Boolean;
|
||||
class TimeUtil
|
||||
{
|
||||
|
||||
private static function comparisonNow(): ?\DateTimeImmutable
|
||||
{
|
||||
$comparisonNow = getenv('REF_COMPARISON_NOW');
|
||||
if (
|
||||
getenv('REF_DETERMINISTIC_INSTALL_ENABLED') !== '1'
|
||||
|| !is_string($comparisonNow)
|
||||
|| $comparisonNow === ''
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return new \DateTimeImmutable($comparisonNow);
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
public static function DateToday()
|
||||
{
|
||||
@@ -87,7 +100,7 @@ class TimeUtil
|
||||
|
||||
public static function now(bool $withFraction = false): string
|
||||
{
|
||||
$obj = new \DateTime();
|
||||
$obj = static::comparisonNow() ?? new \DateTimeImmutable();
|
||||
return static::format($obj, $withFraction);
|
||||
}
|
||||
|
||||
@@ -182,11 +195,19 @@ class TimeUtil
|
||||
}
|
||||
|
||||
public static function nowDateTime(): \DateTime{
|
||||
$comparisonNow = static::comparisonNow();
|
||||
if ($comparisonNow !== null) {
|
||||
return \DateTime::createFromImmutable($comparisonNow);
|
||||
}
|
||||
$now = time();
|
||||
return static::secondsToDateTime($now, false, true);
|
||||
}
|
||||
|
||||
public static function nowDateTimeImmutable(): \DateTimeImmutable{
|
||||
$comparisonNow = static::comparisonNow();
|
||||
if ($comparisonNow !== null) {
|
||||
return $comparisonNow;
|
||||
}
|
||||
$now = time();
|
||||
return static::secondsToDateTime($now, true, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user