I'm working with an older Rails project (recently migrated from Rails 2 to Rails 3) that has some existing code that uses Date.parse to convert a String to a Date and then puts that into an ActiveRecord model where it becomes an ActiveSupport::TimeWithZone class.
In Rails 2 this worked fine; but handling of time zones changed between 2 & 3. Now I see inconsistent behavior on the same code base between Mac & CentOS.
On the Mac the Date converts into the TimeWithZone correctly and keeps the same Date. On CentOS the TimeWithZone is always converted to 1 day prior to the actual date. I'm not sure why this is happening as both systems have time zone set to America/Chicago.
Here is a sample of what happens.
df = Date.parse(a_string)
record.date_with_tz = df # <-- On Mac date_with_tz will have correct date; on CentOS is previous day.
record.save
Aucun commentaire:
Enregistrer un commentaire