This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from decimal import Decimal | |
import re | |
import datetime as dt | |
# Regex could be optimized: | |
# - Only capture first letter of time unit | |
# - Lower string beforehand and remove re.IGNORECASE | |
# - Only allow day digit count of <= 9 (deltatime limit is 999_999_999 days) | |
# I decided not to, because one might want to track those | |
# differences of user input in their own implementation. |