Truncate_time_range.rst 580 B

12345678910111213141516171819
  1. Truncate time range
  2. -------------------
  3. :Sample Code:
  4. .. code:: python
  5. from datetimerange import DateTimeRange
  6. time_range = DateTimeRange("2015-03-22T10:00:00+0900", "2015-03-22T10:10:00+0900")
  7. time_range.is_output_elapse = True
  8. print("before truncate: ", time_range)
  9. time_range.truncate(10)
  10. print("after truncate: ", time_range)
  11. :Output:
  12. ::
  13. before truncate: 2015-03-22T10:00:00+0900 - 2015-03-22T10:10:00+0900 (0:10:00)
  14. after truncate: 2015-03-22T10:00:30+0900 - 2015-03-22T10:09:30+0900 (0:09:00)