Time.zone
有一个
parse
ActiveSupport::TimeWithZone
:
>> Time.zone.parse "October 4 1984"
=> Thu, 04 Oct 1984 00:00:00 EDT -04:00
让它和慢性病一起玩,也许
this article
能帮忙吗?例如,如果你要修补
parse_with_chronic
ActiveSupport::TimeZone
,然后可以重写方法:
def set_dates
unless self.natural_date.blank? || Time.zone.parse_with_chronic(self.natural_date).blank?
# check if we are dealing with a date or a date + time
if time_provided?(self.natural_date)
self.date = nil
self.time = Time.zone.parse_with_chronic(self.natural_date)
else
self.date = Time.zone.parse_with_chronic(self.natural_date).to_date
self.time = nil
end
end
end