-
Notifications
You must be signed in to change notification settings - Fork 105
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
Time zone trouble with time_ago_in_words #63
Comments
The 1 hour difference seems to come from:
Which is weird in itself, because the time zone is actually 2 hours in front of GMT:
Does dotiw do something especially, when accounting for summer time (like CEST)? |
No, dotiw does nothing special when accounting for any particular timezone. |
It's possible this bug is caused by using |
The Time.zone.now fix helped, but there's still a bug here if someone passes both times in: [28] » from_time = Time.zone.now I think the cause is here: Are these necessary? It seems that subtracting times already handles dst properly, and these are actually causing bugs. |
I agree with @arjun810's analysis. I think the problem lies in that I think it is better to leave it to Ruby/Rails to handle time zones and DST. http://apidock.com/rails/ActiveSupport/Duration/from_now |
I will submit a PR to remove the weird time zone adjustment lines, which shouldn't be needed anymore. |
I recently ran into this problem using the last version of the gem and I see the last response to this thread is from over a month ago. Any ideas on how to solve it or any workaround/patch to apply? |
I can easily reproduce the issue with the following example:
and of course this (almost) works:
So forcing time to UTC seams to solve the issue, just like if comparison were done without handling timezone. |
I tried just removing the time zone adjustments to see if using |
Just my 2 cents here: we have an issue with this gem and clockwork_web gem, all timestamps are off by an hour
I think when we are speaking about time difference, we really don't care about th timezone, because essentially things happen at one specific point in time, timezones just define the way we show those points (timestamps), but for two specific moments in time the distance between them is always the same and doesn't depend on timezone So I do think that converting to |
I think it's because it calcluates differences in times and not in dates. The specs are failing when run in a different timezone, despite the timezone set to UTC, e.g.
Also
When working with dates, the calculation should do the calculation as dates, instead of converting them to times. If your app doesn't care at all about timezones, a workaround is to set the |
I would like this to be documented/improved. Please contribute! |
I believe this issue has been fixed by #128 |
@ivanovv , still not fixed, e.g. the specs are still failing when running |
interesting! it is def fixed for my use case 5.3.2
it says 5.3.3
|
@shaicoleman What's your output? Maybe it matters what time of day these specs run? :) Passes on my machine rn (EST 1:120PM). |
The following timezones have failing specs (Ubuntu 20.04, Ruby 2.7). Different timezones have different failing specs
With other timezones, the specs pass, e.g.
Sample script to test over different timezones
|
There seems to be a problem with how dotiw overwrites the
time_ago_in_words
method with respect to handling of time zones.Maybe because it is using
Time.now
instead ofTime.zone.now
?With dotiw:
As you can see, there comes an extra hour there. I don't know why.
In another app, without dotiw:
The text was updated successfully, but these errors were encountered: