DateTimeRange是一个处理时间范围的Python库。例如,检查一个时间是否在时间范围内,得到时间范围的交集,截断一个时间范围,遍历一个时间范围,等等。
DateTimeRange的Python项目详细描述
datetimerange
Examples
Create and convert to string
Sample Code: | ^{pr 1}$ |
---|---|
Output: | ^{pr 2}$ |
Get iterator
Sample Code 1: | ^{pr 3}$ |
---|---|
Output 1: | ^{pr 4}$ |
Sample Code 2: | ^{pr 5}$ |
Output 2: | ^{pr 6}$ |
Test whether a value within the time range
Sample Code: | ^{pr 7}$ |
---|---|
Output: | ^{pr 8}$ |
Test whether a value intersect the time range
Sample Code: | ^{pr 9}$ |
---|---|
Output: | ^{pr 10}$ |
Make an intersected time range
Sample Code: | ^{pr 11}$ |
---|---|
Output: | ^{pr 12}$ |
Make an encompassed time range
Sample Code: | ^{pr 13}$ |
---|---|
Output: | ^{pr 14}$ |
Truncate time range
Sample Code: | ^{pr 15}$ |
---|---|
Output: | ^{pr 16}$ |
Installation
pip install DateTimeRange