I have the following Mongoid model...
class Eve开发者_运维百科nt
include Mongoid::Document
include Mongoid::Timestamps::Created
include Mongoid::Timestamps::Updated
include Mongoid::MultiParameterAttributes
key :name
field :name
field :begins_at, type: Time
field :ends_at, type: Time
belongs_to :city
attr_accessor :time_zone
end
I'd like to be able to have a per-event TimeZone. Obviously due to the complications of time zones the best way to handle this is to store times in UTC when going to the DB and convert back to the event's time zone on the way out of the DB.
I know ActiveRecord has support for this and I was wondering if Mongoid has any kind of native support for this.
Store as: timestamp and when query Format to timezone
精彩评论