Skip to content
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

timezone parsing for native abbreviated UTC fails #152

Open
benaryorg opened this issue May 25, 2023 · 0 comments
Open

timezone parsing for native abbreviated UTC fails #152

benaryorg opened this issue May 25, 2023 · 0 comments

Comments

@benaryorg
Copy link

My timezone is set to UTC, which means that the API (apparently) uses the usual shortened version also described in ISO 8601 or the more accessible RFC 3339 section 2, for instance: 2023-05-24T20:43:16Z.
This in turn causes issues with not just the implementation in ext/date (i.e. the std::chrono::parse polyfill due to some compilers like GCC not yet having fully implemented C++20), but the actual definition of the parser as far as I can tell from various places around the internet, among them some documents from people involved in the standards, previews of how the new API is to be used, but probably easiest the cppreference on std::chrono::parse, which describes the format as being a time offset, not mentioning the possible Z suffix for UTC at all for the %z format, which is used in the code:

stream >> date::parse("%FT%T%Ez", t);

Which prevents any results from being properly parsed, making all dates the unix epoch of 1970-01-01 and yielding this error message:

Failed to parse date '2023-05-24T20:43:16Z' on site Danbooru

I haven't found anything on how to properly parse RFC 3339 strings using C++ in that regard, but it seems that the corresponding parsing would've to be split into one using the above format and another fallback using something like date::parse("%FT%TZ", t); which would have to hard set the timezone for that result to UTC.

The issue seems to be specifically with the data returned from the Danbooru API, as changing the timezone in the account settings works, changing the local timezone (i.e. running as env TZ=Europe/Vienna ahoviewer) does not change the outcome.
When not using any credentials to log in (i.e. account-specific settings are not active) it works too.

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

No branches or pull requests

1 participant