shortener
shortener copied to clipboard
Fixed an issue with links' expiration time.
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.
@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
@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.