@classmethod
def utcfromtimestamp(cls, t):
"""Construct a naive UTC datetime from a POSIX timestamp."""
- t, frac = divmod(t, 1.0)
- us = int(frac * 1e6)
-
- # If timestamp is less than one microsecond smaller than a
- # full second, us can be rounded up to 1000000. In this case,
- # roll over to seconds, otherwise, ValueError is raised
- # by the constructor.
- if us == 1000000:
- t += 1
- us = 0
- y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
- ss = min(ss, 59) # clamp out leap seconds if the platform has them
- return cls(y, m, d, hh, mm, ss, us)
+ return cls._fromtimestamp(t, True, None)
- # XXX This is supposed to do better than we *can* do by using time.time(),
- # XXX if the platform supports a more accurate way. The C implementation
- # XXX uses gettimeofday on platforms that have it, but that isn't
- # XXX available from Python. So now() may return different results
- # XXX across the implementations.
@classmethod
def now(cls, tz=None):
"Construct a datetime from time.time() and optional time zone info."
Library
-------
- towards zero (ROUND_DOWN). It's important that these methods use the same
- rounding mode than datetime.timedelta to keep the property:
+ - Issue #23517: Fix rounding in fromtimestamp() and utcfromtimestamp() methods
+ of datetime.datetime: microseconds are now rounded to nearest with ties
+ going to nearest even integer (ROUND_HALF_EVEN), instead of being rounding
++ towards minus infinity (ROUND_FLOOR). It's important that these methods use
++ the same rounding mode than datetime.timedelta to keep the property:
+ (datetime(1970,1,1) + timedelta(seconds=t)) == datetime.utcfromtimestamp(t).
+ It also the rounding mode used by round(float) for example.
+
+- Issue #25155: Fix datetime.datetime.now() and datetime.datetime.utcnow() on
+ Windows to support date after year 2038. It was a regression introduced in
+ Python 3.5.0.
+
+- Issue #25108: Omitted internal frames in traceback functions print_stack(),
+ format_stack(), and extract_stack() called without arguments.
+
+- Issue #25118: Fix a regression of Python 3.5.0 in os.waitpid() on Windows.
+
- Issue #24684: socket.socket.getaddrinfo() now calls
PyUnicode_AsEncodedString() instead of calling the encode() method of the
host, to handle correctly custom string with an encode() method which doesn't