From deb735d22f3c6e1b79c1494795de4e5b51b5bf3f Mon Sep 17 00:00:00 2001 From: __anuragdaksh7__ <84393491+anuragdaksh7@users.noreply.github.com> Date: Thu, 2 Nov 2023 00:10:19 +0530 Subject: [PATCH] Update _pydatetime.py solved #111513 solved issue with datetime.datetime.fromtimestamp and datetime.datetime.utcfromtimestamp with string arguments --- Lib/_pydatetime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/_pydatetime.py b/Lib/_pydatetime.py index bca2acf1fc88cf..533973d24b0eab 100644 --- a/Lib/_pydatetime.py +++ b/Lib/_pydatetime.py @@ -970,7 +970,7 @@ def __new__(cls, year, month=None, day=None): @classmethod def fromtimestamp(cls, t): "Construct a date from a POSIX timestamp (like time.time())." - y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) + y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(float(t)) return cls(y, m, d) @classmethod @@ -1808,6 +1808,7 @@ def fromtimestamp(cls, timestamp, tz=None): @classmethod def utcfromtimestamp(cls, t): """Construct a naive UTC datetime from a POSIX timestamp.""" + t = float(t) import warnings warnings.warn("datetime.utcfromtimestamp() is deprecated and scheduled " "for removal in a future version. Use timezone-aware "