Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3534

TimeWithZone and dynamic fields

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • None

      According to the documentation website, TimeWithZone is not in the list of types that don't work with dynamic attributes, and I can store an ActiveSupport::TimeWithZone just fine to a dynamic field, but it seems to be always deserialised to a Time class, and it appears to be stored as UTC in the MongoDB

      Is this the expected behaviour?

      [20] pry(main)> time = ActiveSupport::TimeZone.new('Sydney').parse('1/1/2014 11:56pm')
      => Wed, 01 Jan 2014 23:56:00 EST +11:00
      [21] pry(main)> p = Person.last
      => #<Person _id: 5302a1d74a616b58a8280000, created_at: 2014-02-17 23:57:11 UTC, updated_at: 2014-02-18 03:46:36 UTC, tags: [], first_name: "asdasd", last_name: "dssd", email: "">
      [22] pry(main)> p['mytimezone'] = time
      => Wed, 01 Jan 2014 23:56:00 EST +11:00
      [25] pry(main)> p['mytimezone'].class
      => Time
      [23] pry(main)> p.save
      => true
      [25] pry(main)> p['mytimezone'].class
      => Time
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            jakcharlton jakcharlton
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: