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

Use Time.zone.now instead of Time.now(.utc)

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 8.0.1
    • Affects Version/s: None
    • Component/s: None
    • Minor Change

      Mongoid currently uses Time.now or Time.now.utc for setting timestamps:

      lib/mongoid/timestamps/created.rb:          time = Time.now.utc
      lib/mongoid/timestamps/updated.rb:          self.updated_at = Time.now.utc unless updated_at_changed?
      lib/mongoid/touchable.rb:        current = Time.now
      

      This is counter to our documentation (https://www.mongodb.com/docs/mongoid/master/reference/configuration/#time-zones) in which we recommend using Time.zone.now.

      I think Time.zone.now is the correct usage (I also don't understand the reason for explicit conversion to UTC).

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: