Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upEurope/London TZ Goes back an Hour #51
Comments
|
I am not sure how having this issue helps. |
|
I guess it doesn't. I was hoping I'd be able to replicate and track down the issue, and maybe submit a fix. So, I though it might serve as a placeholder in case you were already working on it. However, I'm still at no dice for replication, so I've closed the issue for now. |
|
Yes, replicating would help. The failing tests are, as it happens, on machines set up by Prof Ripley. I simply suspect something local. He may not set TZ. Or he may set TZ to something weird. I am not at all worried about the Fedora failures because these days we do have alternative with the r-hub builders. And there it seems to pass on all Linux flavours (or at least the ones I call regularly via As for the Solaris builds, I'd fix it if I had infinite time or patience. On this planet, I have neither so I have not yet bothered with a VM for slowlaris. You are of course absolutely correct that either issue should be fixed. So I'd love to have PRs or resolution. But I just had to snark that copying a bug report from one system to another does not it, by itself, help. |
|
No PR or resolution yet, but progress on replication suggesting that perhaps the cause of the error is not entirely idiosyncratic or an issue with the TZ environmental variable per se. Recording here in case someone else picks this up. I was able to replicate on a local system (OSX) using For reference, the machine is set to US/Central without an environmental variable.
So, in US/Central / No TZ envir var, things are fine. Trying with an explicit set of TZ Europe/London
Hrm, that shouldn't be. More exploration...
However, this is specific to TZ Europe/London so far. Things were fine under TZ = "Europe/Berlin" and "Etc/UTC". More mysteriously,
As one might expect, links to |
is always false on my now system too. Did you mean
As for the rest of your post, I am not sure I understand what it is you are trying to "prove". |
|
I need to review what I wrote and what the system is doing with regards to the equality. It looks like you may be pointing to a conceptual error on my part there, and I'd like to think about that more. The key result that seems odd to me ATM is that for 'anytime(as.character(Sys.time()))' the resulting time is printed as one hour earlier than 'Sys.time()' under Europe/London; however the results are printed identically under other settings for TZ. Clearly, that probably is the fault of something that anytime depends on rather than anytime itself. I'm going to fork, get this under Travis, and investigate the tests. I'll avoid leaving another comment unless I have a solution in hand. |
|
Look at some of the issue tickets. Such "we miss an hour damnit" issues have been discussed ad nauseum. I think I finally nixed them around 0.2.0 when I decided to convert to date internally. Some of the unit tests are pretty explicitly looping over hundreds of TZ values checking this. That said, I may of course have a thinko or design bug or code bug in there. So by all means go crazy. But keep in mind at the tires have gotten kicked quite a bit too, so if something is funny it could also be on your side. |
|
Suppose it was "Europe/London". What minimal test case can we construct to lay the blame with Boost Date_Time, or R for that matter? Which is of the two sides is "wrong"? If it were R, should we see the error only on Windows as R generally relies on system timezone files on other operating systems. |
|
So here is a more minimal replication, in a Docker container with current R and everything, and First, the R side: > options("digits.secs"=6)
> ref <- format(as.POSIXct(c("2016-09-01 10:11:12", "2016-09-01 10:11:12.345678"), "%Y-%m-%d %H:%M:%0S"))
> ref
[1] "2016-09-01 10:11:12.000000" "2016-09-01 10:11:12.345678"
> Then the failing (only under Europe/London) side:
Somehow Boost thinks it needs to take an hour off. I have no idea why. If you find why, or find a patch, you're my hero. Until then it remains an open issue, seemingly affecting only Europe/London. |
|
Also note the warnings in the R documentation about non-existing or bad TZ values. This seems saner:
These all work. So maybe the error is with ... Europe/London. |
|
Why did you reopen it? It's still not an error in anytime apart from the fact that we chose to rely on Boost. But I guess under the current title it is ok. I was thinking to at least add a note to the documentation to avoid 'Europe/London'. We could even go nuclear and test for Europe/London on .onLoad and reset to TZ if we find it. Maybe a little harsh. Food for thought. |
|
I reopened because I saw this as a confirmed 'issue' in so far as that a given input yields an unexpected output. I suspect that other users have no way of knowing this is Boost's problem unless they see this issue, and an open issue seems to me to be more visible than a closed issue. However, all of the above reflect a stylistic choice and I see it is inconsistent with what you decided to do with the Australia issue. So, go ahead and close, if that is your choice. I'll leave some notes for future travelers:
Shows that as far as Boost is concerned, epoch midnight in Europe/London is 3600 seconds before 0... and it would seem that R agrees.
Notably the timezone is BST, British Summer Time... in the dead of winter (+1 UTC Offset). The British at the time were experimenting with keeping BST year-round, see the Wikipedia section on 'Periods of deviation'. So of course the seconds since epoch is -3600. We can see how this echoes forward to the date they abolished the experiment (coinciding with the regular end of BST), between October 31st and November 1st 1971.
Watching the seconds since epoch by unclassing these 1971 results and examining the C++ variables as they work, you'll see that for both times Back to 1971, we can perhaps see the issue more starkly. In contrast to boost/anytime that believes 24 hours have elapsed between 1971-10-31 and 1971-11-01, R believes that 25 hours have elapsed.
Incidentally unclassing as.POSIXlt results will show that R too doesn't consider 1970-10-31 to be a DST. |
|
Here is another simpler (?) look at the issue. It uses R and What are your thoughts?
(Oh, and I hacked that quickly on the way in on the train -- it uses littler and its |
|
I like that it is concise. Yours shows that there is a problem, mine I think shows pretty precisely where Boost went wrong. Specifically, they failed to count the extra hour that occurred when Europe/London reverted from year-long BST to GMT. I see your name around StackOverflow on a fair number of Boost questions. It seems like a bug report from you would be better formatted and more likely to attract attention than one from me. Do you have time to submit one? |
|
I just pinged a former colleague who, as I recall, has submitted to Boost before. I do think it is worth it. But first things first: thanks the second set of eyes. You concur that R is 'correct' while 'Boost' seems to be off? In which case a bug report seems in order. |
|
Obviously, I need to rewrite the little example in terms |
|
And as far as anytime is concerned: shall we 'catch' use of Europe/London and just a) warn (that I wrote as proof-of-concept) or b) convert to UTC or c) both? |
|
I concur that R seems correct while Boost seems to be off. In relationship to |
|
It is not Boost. See the file london.cpp I added, it builds with a simple We don't link with Boost, and we don't give Boost its timezone information so it is the system. And epoch is simply BST:
So in short maybe we see no bug, The epoch was after all at UTC. And Europse/London is BST. |
|
To match your
I'm seeing a difference in seconds between the two approaches on my machine. Can you confirm? Or does the above not matter? |
|
Run it repeatedly. There is something weird going on with the C library. On occasion I have seen the value flip. edd@max:~/git/anytime/local(master)$ TZ=Europe/London ./london '1980-01-01 00:00:00'
Boost secs from epoch: 315529200 Input: 1980-01-01 00:00:00 ptime: 1980-Jan-01 00:00:00
C library secs : 315529200 secs off: 0 tmzone GMT
edd@max:~/git/anytime/local(master)$ Now of course I can't reproduce it. |
|
That's really odd. I wasn't able to reproduce instability on my end. I wonder what boost could be doing to possibly cause that? At the very least, it seems like the bug is still on Boost's end with the typical behavior being 'bugged'.
|
|
Apologies for a screenshot, but I still had the terminal open on my (very standard) laptop (running Ubuntu 16.10): It seems to flip somewhat randomly. Not that there is little Boost in this (besides of course the templated headers): edd@brad:~/git/anytime/local(master)$ ldd london
linux-vdso.so.1 => (0x00007ffd38b7f000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8353462000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f835324b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8352e84000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8352b7b000)
/lib64/ld-linux-x86-64.so.2 (0x00005646e11ab000)
edd@brad:~/git/anytime/local(master)$ I think the timezone information comes straight from the system. |
|
Also note that this post of yours shows flipping values whereas this post of yours says you do not see them. |
|
I think we are miscommunicating. I took 'flipping' to mean inconsistent results across runs. I.e., sometimes both programatic pathways in london.cpp yield the same result, sometimes they yield different results. I do not see inconsistent results across runs. Note that that test is just about whether the output from london.cpp stays the same, not about whether the outputs from the two pathways agree. Although I do see is consistent results across runs, the consistent result is a disagreement between the two programatic pathways in london.cpp as shown here. That being said, I'm using a Mac for this test and I'd wager you're on Debian, and so perhaps that is why you get flipping values and I do not. Regardless, the root of the problem is drifting pretty far out of my core competencies at this point. So, I am at a loss as to how to proceed. |
|
Europe/London is BST which in Jan 1970 was an hour before UTC. Maybe we concluded that there is no bug. |
|
Wikipedia on British Standard Time, Section 2:
And that seems to pan out:
On Oct 31 we do have an offset to GMT, and a BST timezone, on Nov 1 we do not. |
|
Yes, the confusion /bug if one exists does seem to be related to the BST weirdness between 1970 and 1971. To me it seems the 'trick' is that between midnight on October 31st (BST) and midnight November 1st (GMT), 25 hours elapse, not 24 (i.e. 86400 seconds). When you get the intermittent 'bad' result from the Boost pathway it'll look something like this:
For Boost seconds since epoch has a delta of 86400, 24 hours. For C seconds since epoch has a delta of 90000, 25 hours. IDK if it is relevant, but I'll also resurface that in my earlier ('yes') post, I noticed that Boost does not report 1970-10-31 as having a dst adjustment. |
|
So I think a good summary is that is appears to be a bug on the Boost side: $ TZ="Europe/London" Rscript -e 'print(anytime::anytime(c("1971-10-31 00:00:00", \
"1971-11-01 00:00:00")))'
[1] "1971-10-31 00:00:00 BST" "1971-10-31 23:00:00 GMT"
$ For any other time zone, the zero hour is preserved: $ TZ="Europe/Berlin" Rscript -e 'print(anytime::anytime(c("1971-10-31 00:00:00",
"1971-11-01 00:00:00")))'
[1] "1971-10-31 CET" "1971-11-01 CET"
$ |
|
I may have something now, due to the persistent nagging by @statquant and the excellent ground-work by @drknexus. I will commit a new branch in a second. It passes this existing test now:
A new file in |
|
Here is what the new tests shows -- I think I got the cut-over point right but would really appreciate a second set of eyes:
|
|
No luck, though, as this leads to a failure with |
|
Take two -- it is actually the setup timezone that matters as it is the one governing the Boost behavior. Now we compare to that one. Looks better at Travis. This may actually work. |

I haven't been able to independently reproduce this issue, however, as I'm sure you are aware anytime is failing on R-devel for some platforms. I didn't see an open issue here, so I thought I'd open one such that I could track it. It could very well be a fault in R-devel as opposed to anytime per-se. However, given that I haven't been able to reproduce the issue, I'm in a tough place in terms of evaluating whether that is so. What are your thoughts/impressions?