This project is archived and is in readonly mode.

#4076 ✓wontfix
Reinier de Lange

ago (ActiveSupport::CoreExtensions::Numeric::Time) does not respect current timezone

Reported by Reinier de Lange | March 1st, 2010 @ 09:25 AM

When calling 'ago' without parameters (so: ago(time = ::Time.now)), it returns an unexpected result as the timezone is disregarded. For example, see the following session:

  Loading production environment (Rails 2.3.4)
  >> Time.now
  => Mon Mar 01 00:12:04 +0100 2010
  >> Date.today
  => Mon, 01 Mar 2010
  >> 1.month.ago(Date.today)
  => Mon, 01 Feb 2010
  >> 1.month.ago(Time.now)
  => Mon Feb 01 00:12:51 +0100 2010
  >> 1.month.ago
  => Thu, 28 Jan 2010 23:12:57 UTC +00:00

I find it very confusing that 1.month.ago is not the same as 1.month.ago(Time.now). It is not clear to me whether this is a feature or a bug, but imo it should be changed.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Tags

Referenced by

Pages