Skip to content

Conversation

@cwaldren-ld
Copy link
Contributor

@cwaldren-ld cwaldren-ld commented May 11, 2023

Fixes the handling of timezones when parsing the Date header from HTTP responses.

The problem was that the date given by servers is GMT, but code was interpreting that in the local host's timezone, leading to an 8 hour offset for me. Instead, we need to obtain the offset and subtract that out of the parsed result.

@cwaldren-ld cwaldren-ld marked this pull request as ready for review May 11, 2023 20:16
if (!event.require_full_event) {
return;
}

Copy link
Contributor Author

@cwaldren-ld cwaldren-ld May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bugfix: debug event emit logic shouldn't be gated by require_full_event (which right now is equivalent to the flag's track_events prop.)

@cwaldren-ld cwaldren-ld requested a review from kinyoklion May 11, 2023 20:25
std::istringstream string_stream(datetime);
string_stream.imbue(std::locale("en_US.utf-8"));
string_stream >> std::get_time(&gmt_tm, "%a, %d %b %Y %H:%M:%S GMT");
if (string_stream.fail()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugfix: simply parsing using std::get_time followed by mktime gives us a std::chrono::system_clock::time_point in local time. We need to actually compute the offset and subtract it out.

This code is just so painful. C++20 has a parse method which might help, or we can import a 3rd party library..

@cwaldren-ld cwaldren-ld merged commit 548d750 into main May 12, 2023
@cwaldren-ld cwaldren-ld deleted the cw/debug-event-fixes branch May 12, 2023 18:23
@github-actions github-actions bot mentioned this pull request May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants