Welcome to time_str’s documentation!¶
Time_str¶
A package to convert user input into datetime.timedelta objects.
PyPI: https://pypi.org/project/time-str/
Docs: https://time-str.readthedocs.io/en/latest/
Installation¶
You can install released versions of time_str from the Python Package Index via pip or a similar tool:
Stable Release: pip install time_str
Working Version: pip install git+https://github.com/BobDotCom/time_str.git
Usage¶
>>> import time_str
>>> time_str.convert('11 months 9days 1m 3 sec')
datetime.timedelta(days=345, seconds=63)
>>> time_str.convert('2 months 3w 1 d 5hour 3 min')
datetime.timedelta(days=83, seconds=18180)
- class time_str.Converter(input_string)¶
A converter to convert a string to a
datetime.timedelta
object. The convert method returns adatetime.timedelta
object- input_string:
str
A string (usually user input) to convert to a
datetime.timedelta
object. This can be set during initialization.
- convert()¶
The converter itself. Takes the string input from initialization and transforms it into a
datetime.timedelta
object.datetime.timedelta
The converted datetime.timedelta object.
- input_string: