-
Notifications
You must be signed in to change notification settings - Fork 683
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
tzdata bad parse for Mexico April 1931, bad dow name #836
Comments
Based on the other lines, I believe it was expecting Apr, but it received April, so the next parse3() call got il\t (the leftovers) |
I've requested a fix to the IANA database: https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/LBVCBNK5NPWBNQ5UDUY3YEZPWA2QV262/ |
Any simple/quick fixes in the meantime? |
I just edited the northamerica file and changed April to Apr and it worked fine |
That works. Or you could grab 2024a from https://github.com/eggert/tz/tree/380c07cef01c71c1f93e9709d9f8c79b91cff063 and compile with More details on this option here: https://howardhinnant.github.io/date/tz.html#Installation |
The fix is on its way: eggert/tz@926b507 Not sure how long before release. |
Just to expand on @spannella earlier workaround post. If you are automatically downloading updated versions of the tz data - and you probably are if you are seeing this error - the tz data files are downloaded to your users dowloads folder. E.g. if you are running on a macOS machine this would be the users If you are running jobs via agents or daemons as Locate the Thank you for a great library ❤️ |
Hi @HowardHinnant - the IANA thread you link to also indicates they think full month names are valid. To avoid this in the future should the parser be modified to permit these? |
Possibly, but that's low priority for me. This library is obsoleted by C++20. I realize that implementations are still coming online and that this library will need to continue to exist for a couple more years. IANA has no real motivation to use full month names. And doing so breaks more tools than just this one. |
Just a proposed fix (didn't do up a pull request for it yet) but I am using this currently for myself: static
std::string
parse_until_whitespace(std::istream& in)
{
std::string result;
in >> result;
return result;
}
static
unsigned
parse_month(std::istream& in)
{
CONSTDATA char* const month_names[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
std::string s = parse_until_whitespace(in);
auto it = std::find(std::begin(month_names), std::end(month_names), s);
auto index = it - std::begin(month_names);
if (it == std::end(month_names))
throw std::runtime_error("oops: bad month name: " + s);
return static_cast<unsigned>((index % 12) + 1);
} |
Thanks. I sincerely appreciate the suggestion. A few constructive comments:
In summary, to strictly follow their spec is a fair amount of work, and will likely add to the run-time expense of doing the parse (at least a little). Certainly doable. But I don't see the point of taking advantage of all this flexibility within the IANA database. It makes more sense for the single IANA db to follow a more strict syntax, and pass the savings in parsing complexity onto the several parsers. I don't know this, but I would not be surprised that if they took full advantage of all this flexibility in their spec that they would break their own parser. They just received another report of a broken parser: Azul ZUUpdater Tool. |
Thank you, this works like a charm. |
No, that parser won't break. For example, TZDB ships, and various distros use, a file tzdata.zi that contains lines like this:
where Every |
A TZDB user reports, "The library https://github.com/HowardHinnant/date will check for latest release and it auto downloads the latest version. With latest version and scheduler is broken." He write that there is no option to stick with TZDB release 2024a. I don't know whether the breakage is a problem with the TZDB users's configuration or with |
To be clear, we went with default setting of auto download and released into our agents. After this issue, we realized there is a option to turn off auto download tz db files , we are releasing a patch with it. But to recompile it and release it to all the agents is not a quick solution and it requires an app upgrade in our case for all the customers. We rely on date lib for timezone conversions, as date lib is unable to load tzdb files the scheduler functionality is broken. |
Thank you both @eggert and @ironman198 for the further information. I would also like to make a further clarification. This won't directly help either of you as I know you both already know this. Rather this clarification is for the wider audience reading this thread:
I also note that this library is obsoleted by the MSVC implementation of C++20 chrono, and the gcc implementation of C++20 chrono. An LLVM implementation of C++20 chrono is still under development. I also know that the gcc implementation is not impacted by the 2024b release from IANA. I'm unsure if the MSVC implementation is impacted. Also tangentially on this subject, here is an article showing how an application can use this library to control if and when a new IANA tzdb is downloaded, and even contend with multiple databases in a concurrent environment. The article was motivated by long running applications which can't reboot but want to take advantage of newly released IANA tzdbs. An airline reservation system might be an example of an application needing this functionality. |
Speaking from an end-user's perspective, it appears that there is a lot of complex thought going into this but I'm not sure it's justified when a very simple patch resolves the current problem and greatly ameliorates the issue moving forward (especially given that IANA says you should support full month names). I'm just one user but this issue forced me to refactor this library out of all production apps. It remains only in a single non-production application at this time. |
# Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Mexico 1931 only - April 30 0:00 1:00 D
Seems to fail to parse April in northamerica which is causing tz.cpp:825 to throw:
std::runtime_error("oops: bad dow name: il")
The text was updated successfully, but these errors were encountered: