提交 b48c9bb5 编写于 作者: C Charlie Somerville

respect ActiveRecord::Base.default_timezone

上级 361f872c
......@@ -5,12 +5,18 @@ module Time #:nodoc:
module Conversions
DATE_FORMATS = {
:db => lambda { |time|
# our DB is in local time (ugh), so make sure the time object is
# converted to local time before converting it to a db string
#
# also we have to do this ridiculous dance to ensure that we can
# turn any given DateTime object into something in localtime.
time.utc.to_time.getlocal.strftime("%Y-%m-%d %H:%M:%S")
time = time.utc.to_time
if !defined?(ActiveRecord::Base.default_timezone) || ActiveRecord::Base.default_timezone == :local
# our DB is in local time (ugh), so make sure the time object is
# converted to local time before converting it to a db string
#
# also we have to do this ridiculous dance to ensure that we can
# turn any given DateTime object into something in localtime.
time = time.getlocal
end
time.strftime("%Y-%m-%d %H:%M:%S")
},
:number => "%Y%m%d%H%M%S",
:time => "%H:%M",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册