You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing a timedelta now only works when the timedelta is constructed using seconds. You're using the .seconds of a timedelta but that's only the "seconds" component of it. For example:
>>>d=timedelta(days=1)
>>>d.seconds0
You should convert the timedelta to seconds using total_seconds():
>>>d.total_seconds()
86400.0
You may need to convert this to an integer to use it. Using this method means your project will require Python 2.7+ as that's when total_seconds() was introduced.
The text was updated successfully, but these errors were encountered:
timedelta.total_seconds was also added on python 3.2+ so i will update the code to use the following function:
deftotal_seconds(td):
""" simulates the total_seconds function added in python 3.2+ and 2.7+ See :param td: timedelta :type td: timedelta :return: float representing total seconds from timedelta :rtype: float """return (td.microseconds+ (td.seconds+td.days*24*3600) *10**6) /10**6
Passing a
timedelta
now only works when the timedelta is constructed using seconds. You're using the.seconds
of atimedelta
but that's only the "seconds" component of it. For example:You should convert the
timedelta
to seconds usingtotal_seconds()
:You may need to convert this to an integer to use it. Using this method means your project will require Python 2.7+ as that's when
total_seconds()
was introduced.The text was updated successfully, but these errors were encountered: