I need, passing a datetime value, the next moment.
For example:
input: 2022-11-15 10:23:00 --> output: 2022-11-15 10:23:01
input 2022-11-15 10:59:59 --> output: 2022-11-15 11:00:00
input: 2022-12-31 23:59:59 --> output: 2023-01-01 00:00:00
I tried doing this
date = dateEx + datetime.timedelta(days=1) # not always, only if the
# day ended(?)
timeStr = timeEx.strftime("%H:%M:%S")
timeStr = timeStr.split(":")
timeEx = datetime.time(int(timeStr[0]), int(timeStr[1]), int(timeStr[2]))
StartTime = timeEx + datetime.time(second=1) # trying to get the next moment
Where dateEx
is the previous generated date (format: YYYY-MM-DD) and timeEx
is the previous generated time (format: YYYY-MM-DD HH-MM-SS).
At StartTime = timeEx + datetime.time(second=1)
I get an error: TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.time'