mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 12:47:39 +02:00
Fix PHP7.1 DateTime support
This commit is contained in:
@@ -311,7 +311,8 @@ class Logger implements LoggerInterface
|
|||||||
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
|
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->microsecondTimestamps) {
|
// php7.1+ always has microseconds enabled, so we do not need this hack
|
||||||
|
if ($this->microsecondTimestamps && PHP_VERSION_ID < 70100) {
|
||||||
$ts = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone);
|
$ts = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone);
|
||||||
} else {
|
} else {
|
||||||
$ts = new \DateTime(null, static::$timezone);
|
$ts = new \DateTime(null, static::$timezone);
|
||||||
|
@@ -542,7 +542,7 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
// this has a very small chance of a false negative (1/10^6)
|
// this has a very small chance of a false negative (1/10^6)
|
||||||
'with microseconds' => array(true, 'assertNotSame'),
|
'with microseconds' => array(true, 'assertNotSame'),
|
||||||
'without microseconds' => array(false, 'assertSame'),
|
'without microseconds' => array(false, PHP_VERSION_ID >= 70100 ? 'assertNotSame' : 'assertSame'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user