index.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Examples
  2. ========
  3. :py:class:`datetime.datetime` instance can be used as an argument value as well as
  4. time-string in the following examples.
  5. .. note::
  6. Use not the :abbr:`DST(Daylight Saving Time)` offset, but the standard time
  7. offset when you use datetime string as an argument. :py:class:`~datetimerange.DateTimeRange` class
  8. automatically calculate daylight saving time. Some examples are below
  9. .. code:: console
  10. >>>from datetimerange import DateTimeRange
  11. >>>time_range = DateTimeRange("2015-03-08T00:00:00-0400", "2015-03-08T12:00:00-0400")
  12. >>>time_range.timedelta
  13. datetime.timedelta(0, 39600) # 11 hours
  14. .. code:: console
  15. >>>from datetimerange import DateTimeRange
  16. >>>time_range = DateTimeRange("2015-11-01T00:00:00-0400", "2015-11-01T12:00:00-0400")
  17. >>>time_range.timedelta
  18. datetime.timedelta(0, 46800) # 13 hours
  19. .. include:: Create_and_convert_to_string.rst
  20. .. include:: Compare_time_ranges.rst
  21. .. include:: Move_the_time_range.rst
  22. .. include:: Change_string_conversion_format.rst
  23. .. include:: Add_elapsed_time_when_conversion _to_string.rst
  24. .. include:: Change_separator_of_the_converted_string.rst
  25. .. include:: Get_start_time_as_datetime.datetime.rst
  26. .. include:: Get_start_time_as_string.rst
  27. .. include:: Get_end_time_as_datetime.datetime.rst
  28. .. include:: Get_end_time_as_string.rst
  29. .. include:: Get_datetime.timedelta.rst
  30. .. include:: Get_timedelta_as_seconds.rst
  31. .. include:: Get_iterator.rst
  32. .. include:: Set_start_time.rst
  33. .. include:: Set_end_time.rst
  34. .. include:: Set_time_range.rst
  35. .. include:: Test_whether_the_time_range_is_set.rst
  36. .. include:: Validate_time_inversion.rst
  37. .. include:: Test_whether_the_time_range_is_valid.rst
  38. .. include:: Test_whether_a_value_within_the_time_range.rst
  39. .. include:: Test_whether_a_value_intersect_the_time_range.rst
  40. .. include:: Make_an_intersected_time_range.rst
  41. .. include:: Make_a_subtracted_time_range.rst
  42. .. include:: Make_an_encompassed_time_range.rst
  43. .. include:: Truncate_time_range.rst