thombashi / DateTimeRange

DateTimeRange is a Python library to handle a time range. e.g. check whether a time is within the time range, get the intersection of time ranges, truncate a time range, iterate through a time range, and so forth.
https://datetimerange.rtfd.io/
MIT License
106 stars 16 forks source link

[Feature Request] Create DateTimeRange from String #38

Closed noamsgl closed 3 years ago

noamsgl commented 3 years ago

hi

Love the package.

It would be very useful to be able to construct a DateTimeRange from a single string (e.g. from the string representation), as in: dtr = DateTimeRange("2008-01-03T06:55:29 - 2008-01-03T07:55:29")

thombashi commented 3 years ago

@noamsgl Thank you for your feedback.

You can construct a DateTimeRange from a single string since DateTimeRange 1.2.0:

>>> from datetimerange import DateTimeRange
>>> DateTimeRange.from_range_text("2008-01-03T06:55:29 - 2008-01-03T07:55:29")
2008-01-03T06:55:29 - 2008-01-03T07:55:29