oxidized
oxidized copied to clipboard
More timezone calculation problems (fix pending PR)
TL;DR: in the oxidized-web versions.haml template, the TZ in x[:date]
is corrupt. Looks like it'll probably be wrong in /node/version/diffs, too.
I've gone through all the other time-related tickets, but nothing seems to match what I'm seeing now.
I'm running oxidized v0.28.0 from git commit 0eecddbab026675c89eb199210eb8bce1f7735c7, and oxidized-web from git commit 84c5fd8ea4b6db4a306f7cda489fed4619a85aa8, no local modifications (well... until now!).
On the /nodes page, all the times appear to be correct, so I'm not having the problems most others have had.
But on the /node/version?node_full=DEVICENAME page, all the deltas are offset by precisely the TZ.
I'm in CDT right now, which is GMT-5. Server runs in UTC with TZ set correctly at the system level, not sure how to check if the Ruby process inherited it correctly or not, but is probably correct (see below).
I just made an change to a device and forced a poll. The /node/version page now says the most recent version date is "5 hours 9 min ago" when it was really 9min ago. And I'm in GMT-5. Hmmm. All the device .../version pages show the same thing, it's not just one device. I do not know if this is new, I suspect it's been like this since I started using Oxidized, and I've just never noticed.
When I inspect the HTML source, the dates are formatted a little... oddly: https://XXX/node/version/view?node=XXX&group=&oid=09925c3552b8fe6b86b9ad1402e8301dbf8973ac&date=2022-05-19%2015:56:13%20-+0500&num=31 Granted that's a URL, maybe it's magic...
The Date:
HTTP header on /node/version is correct, just it returned Date: Thu, 19 May 2022 21:18:00 GMT
.
Aha: versions.haml (in oxidized-web) merely contains %td #{time_from_now x[:date]}
, this suggests it's getting dates wrongly offset by TZ from Oxidized.
It is indeed oxidized providing malformed dates to oxidized-web. When I edit versions.haml to show the date as well (via %td #{x[:date]}, #{time_from_now x[:date]}
) the browser now displays 2022-05-19 15:56:13 -+0500, 5 hours 31 min ago
.
I'd be willing to bet that the problem is -+0500
, when it should be simply -0500
. I don't have a clue where the +
is coming from.
Unfortunately, my Ruby comprehension skills are minimal at best, and I'm out of my depth diagnosing any further.
For what it's worth, git log
displays the dates & TZs correctly... I just don't know how to get from there to HTML output. Help?
(I did grep the entire code base for all instances of +
but rapidly decided I had better things to torture myself with than examine all 1012 results by hand.)
Oh for crying out loud, I found the bug 2ms after writing that.
oxidized-web/lib/oxidized/web/webapp.rb, line 268: unless date.include? '+'
.
The bug is that timezones can also be negative.
I do not know the correct Ruby idiom to fix it, though.
Fix applied in PR#228 https://github.com/ytti/oxidized-web/pull/228
I'll have a look at this.
@aschaber1 did you get a chance to look at merging my bugfix? Github handily reminded me it's still outstanding - bad bot :(.