diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d9dcf7..53715b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v6.9.1 (2023-11-20) + +- Fixes a bug that globally reset the timezone to UTC instead of setting the timezone per-request (closes #310) + ## v6.9.0 (2023-10-11) - Deprecates API key-related functions in the `user` service and introduces the replacement functions in the `api_keys` service diff --git a/composer.json b/composer.json index 95b6e97a..621ca9ff 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "easypost/easypost-php", "description": "EasyPost Shipping API Client Library for PHP", - "version": "6.9.0", + "version": "6.9.1", "keywords": [ "shipping", "api", diff --git a/lib/EasyPost/Constant/Constants.php b/lib/EasyPost/Constant/Constants.php index 45c5b7d8..d79d18c4 100644 --- a/lib/EasyPost/Constant/Constants.php +++ b/lib/EasyPost/Constant/Constants.php @@ -11,7 +11,7 @@ abstract class Constants const BETA_API_VERSION = 'beta'; // Library constants - const LIBRARY_VERSION = '6.9.0'; + const LIBRARY_VERSION = '6.9.1'; const SUPPORT_EMAIL = 'support@easypost.com'; // Validation diff --git a/lib/EasyPost/Http/Requestor.php b/lib/EasyPost/Http/Requestor.php index b70db9ac..ef2dae03 100644 --- a/lib/EasyPost/Http/Requestor.php +++ b/lib/EasyPost/Http/Requestor.php @@ -183,9 +183,7 @@ private static function requestRaw($client, $method, $url, $params, $beta = fals ]; $requestUuid = uniqid(); - $originalTimezone = date_default_timezone_get(); - date_default_timezone_set('UTC'); - $requestTimestamp = microtime(true); + $requestTimestamp = (float) (new DateTime('now', new DateTimeZone('UTC')))->format('U.u'); ($client->requestEvent)([ 'method' => $method, 'path' => $absoluteUrl, @@ -226,7 +224,7 @@ private static function requestRaw($client, $method, $url, $params, $beta = fals $responseHeaders = $response->getHeaders(); } - $responseTimestamp = microtime(true); + $responseTimestamp = (float) (new DateTime('now', new DateTimeZone('UTC')))->format('U.u'); ($client->responseEvent)([ 'http_status' => $httpStatus, 'method' => $method, @@ -238,9 +236,6 @@ private static function requestRaw($client, $method, $url, $params, $beta = fals 'request_uuid' => $requestUuid, ]); - // Reset the timezone after we've done our UTC calculations so we don't affect user code - date_default_timezone_set($originalTimezone); - return [$responseBody, $httpStatus]; }