Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3702

Stop using utcnow and utcfromtimestamp

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.4
    • Affects Version/s: 4.4
    • Component/s: None

      Using utcnow and utcfromtimestamp is discouraged:

      Warning Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling datetime.now(timezone.utc).

      https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

      They will likely be deprecated in 3.12: https://github.com/python/cpython/issues/103857

      We should stop using these methods and audit our usage to make sure we don't suffer from the bugs they encourage.

            Assignee:
            noah.stapp@mongodb.com Noah Stapp
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: