-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Timezone is changed and not changed back #310
Comments
Hey @robgridley, thanks for writing in. I'm still not perfectly clear on the ask here. Are you looking to have the timezone your code is running in to be respected when getting the timing metrics of a request hook? We intentionally set UTC to provide a consistent experience for all users. Are you not able to convert the UTC time returned into the timezone you need? |
By using date_default_timezone_set(), you're not just changing the timezone for your library, you're changing the timezone for my application. |
Ah understood, thank you for clarifying! Yeah we'll definitely want to fix that. Let me toss up a PR here shortly and get this resolved. |
Thanks! For now I'm storing my app's timezone and switching it back after every API call. |
Mind double-checking my PR to make sure it's along the lines of what you had in mind? |
Looks good. That's exactly what I'm doing. |
fix: reset timezone to original (closes #310)
Perfect, we'll get this released shortly. Thanks again for reporting this! |
The current fix did not completely resolve this issue. During the process of restoring the time zone, there are HTTP requests (IO operations) involved. In the 'Fiber' or 'Swoole' runtime environment, any IO operation will cause coroutine switching. The current global methods will contaminate the entire process space. Please use the 'DateTime' object to safely resolve this problem.
|
This should be fixed for good with the release of v6.9.1. Let us know if that's not the case! |
Software Version
6.8.1
Language Version
8.1.11
Operating System
Ubuntu
What happened?
Your client is forcing the timezone to UTC to get a UTC timestamp in microseconds, but you're not switching it back. Line 186 in lib/EasyPost/Http/Requestor.php.
What was expected?
As of PHP 7.1 the built-in DateTime class supports microseconds. You can create a new DateTime instance, change the timezone of the instance to UTC, then format it as a timestamp. You could also store the current timezone, set it to UTC, call microtime(), then change the timezone back.
Sample Code
No response
Relevant logs
No response
The text was updated successfully, but these errors were encountered: