meysam81 / timeframe

Python library datetime wrapper for calculating time ranges, manipulations and calculations

Home Page:https://pypi.org/project/timeframe/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError when subtracting a timeframe that includes the other but has equal start

Jonibhoni opened this issue · comments

Python console:

from timeframe import TimeFrame
from datetime import datetime
tf1 = TimeFrame(datetime(2022, 2, 22), datetime(2022, 2, 23))
tf2 = TimeFrame(datetime(2022, 2, 22), datetime(2022, 2, 24))
tf2 - tf1
# 2022-02-23T00:00:00.000001#2022-02-24T00:00:00  (fine)
tf1 - tf2
# -> Exception:
Traceback (most recent call last):
  File "F:\Programme\Python\Python310\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "F:\Programme\Python\Python310\lib\site-packages\timeframe\timeframe.py", line 359, in __sub__
    return TimeFrame(lower, upper)
  File "F:\Programme\Python\Python310\lib\site-packages\timeframe\timeframe.py", line 195, in __init__
    raise ValueError(
ValueError: start should be lower or equal than end: 2022-02-24 00:00:00.000001 & 2022-02-23 00:00:00

PS: Great package otherwise! :) 🥇