aiotense - python time parsing tool.
GitHub - https://github.com/Animatea/aiotense
Documentation - https://animatea.github.io/aiotense/
aiotense is a tool that converts a string like "1day1minute 20seconds" into number of seconds or timedelta objects.
import asyncio from aiotense import TenseParser time_string = "1d2minutes 5 sec" # <-- Digit parser --> digit_parser = TenseParser(TenseParser.DIGIT) digit_value = asyncio.run(digit_parser.parse(time_string)) # <-- Assertions --> assert digit_value == 86525
If you need case insensitivity, you can use resolvers.
Custom parsing sequence - custom resolvers.
Need to convert result to string? You can write your own converter by inheriting
Need to cache the result? Write your own parser by inheriting
aiotense has been designed with maximum flexibility, practicality and user friendliness in mind. I hope our project helped you or you were just interested in seeing it.
Top comments (0)