shortener icon indicating copy to clipboard operation
shortener copied to clipboard

Fixed an issue with links' expiration time.

Open threadedstream opened this issue 3 years ago • 2 comments

Today morning i encountered that links' ability to expire does not function properly. Turned out that unexpired links were filtered using ::Time::current::to_s(:db) routine, which outputs incorrect time for my country (3 hour difference). To mitigate the problem, I just replaced it by ::Time.now. I want to apologize beforehand if there are some issues in the way I wrote the spec test. I'm relatively new to Ruby and am not aware of good practices of writing clean Ruby code.

threadedstream avatar May 12 '21 12:05 threadedstream

@jpmcgrath Time.current is the appropriate method that takes Time.use_zone in to account. Time.now returns the time of the system.

See: https://thoughtbot.com/blog/its-about-time-zones#don39t-use

craigmcnamara avatar Dec 01 '21 06:12 craigmcnamara

@ThreadedStream Is your DB configured to be UTC and is your app default also? Improperly mixing and matching timezone config can be a common source of errors related to timezones. If your DB is in UTC, Rails will properly convert all Time objects passed through ActiveRecord from the app timezone to UTC for the DB. I think I see an error that I addressed in #146 that would cause this to be incorrect in certain cases, but I think DB timezone config sounds like the first place to check.

craigmcnamara avatar Dec 01 '21 06:12 craigmcnamara