-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix test suite #143
fix test suite #143
Conversation
Looks like it is still not passing
|
…he loop The checks are called 4 * 360 * 360, which was leading to having ~30M of test logs.
The last test (loop in a loop) was very obscure specification-wise, and was actually broken - only that its broken-ness was not showing up because the test writer used assert() instead of test assertions, which were elided by the compiler since we compile with optimizations. Rewrite the test trying to follow all the possible corner-cases.
Damn. A major difference with the behavior on my machine is that Could you run |
d9335d8
to
7a99ee5
Compare
OK, so ... I dug even a little bit more. strptime does not change the time fields when given a time zone. %Z is ignored on libc. %z sets a non-standard field (tm_gmtoff). See the source code
mktime assumes its argument to be in local time. There is timegm which does the same for UTC, but then it's also non-standard. To be honest, I don't see a robust way to implement this method without spending an incredible amount of time (and probably still having a few corner-cases). I personally move to deprecate it wholesale and flag it as "don't use, unexpected behaviors may happen in various time zones. If you need to save/load time, save the seconds-since-epoch value returned by toMilliseconds()". |
$timedatectl [12:23:06] What issues would you see if we rely on http://man7.org/linux/man-pages/man3/tzset.3.html which is used by 'date in coreutils' and use "timezone" to set the value to be UTC. btw that is still #109 |
OK, misread the timestamps. The value returned by fromString is 10:05, the expected value is actually 11:05 (once corrected by local time). The test value from the string is 12:05. So, I'm guessing problem detecting summer time since you're currently in winter (+1) and 14/06 was obviously summer. The code assumes that mktime is going to detect summer time. It maybe does, but using the current date and not the date in the tm struct ? Which leads me back to my previous comment:
tzset() initializes the timezone variable, which allows to correct for the effect of mktime, which turns a local time ("local time" being in this case the test value of 12:05) into GMT time. |
If you are in control of the full process ok, but you still might what to read a formatted timestamp from a different source. I see the issue in the assumption of base Time implying local time.. |
Just for the record, since I already said that in #144, but the safest assumption by far is to assume that base::Time stores UTC. |
My conclusion is that if you do need to do that, use another language that has a decent time representation and parsing, and use that language to convert to epoch. C/C++ does not give us the tools to do so, and I'd rather not pull a library in base/types to do that - or spend any more time to do it. I think that having the test suite for the robust parts of base/types passing is of widely more importance. In addition, given that nobody was hit by this situation so far, I'm guessing that these methods are not widely used - or are at least not used to interpret historical data. Hence my position of "let's drop it". For the record (again :P), C++20 will provide the tools for clock conversion it seems. |
I am using it and would prefer not to be forced to look for a replacement - so updated #144. |
7a99ee5
to
df7f01f
Compare
It was not passing. base/types ... !