Skip to content

Time zone trouble with time_ago_in_words #63

@redbar0n

Description

@redbar0n

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 of Time.zone.now ?

With dotiw:

irb(main):010:0> Time.now
=> 2015-09-29 11:57:55 +0000
irb(main):011:0> Time.zone.now
=> Tue, 29 Sep 2015 13:57:59 CEST +02:00
irb(main):016:0> helper.time_ago_in_words(3.minutes.from_now)
=> "1 hour and 2 minutes"

irb(main):018:0> helper.time_ago_in_words(Time.now+3.minutes)
=> "2 minutes"
irb(main):019:0> helper.time_ago_in_words(Time.zone.now+3.minutes)
=> "1 hour and 2 minutes"

As you can see, there comes an extra hour there. I don't know why.

In another app, without dotiw:

2.1.1 :002 > helper.time_ago_in_words(3.minutes.from_now)
 => "3 minutes" 
2.1.1 :003 > helper.time_ago_in_words(Time.now+3.minutes)
 => "3 minutes" 
2.1.1 :004 > helper.time_ago_in_words(Time.zone.now+3.minutes)
 => "3 minutes" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions