A brief overview of some often re-used date methods, which are collectively referred to as tools.
Collection of useful extensions to Python’s datetime module in the standard library. These functions occur so frequently while scripting and have been rewritten in so many places that it makes sense to have one package containing them.
A simple range function over dates
>>> daterange("20130101", "20130103")
["20130101", "20130102", "20130103"]
Parameters: |
|
---|---|
Returns: | list of dates |
Finds missing dates within a sequence of dates
Parameters: | dates – list of dates |
---|---|
Returns: | list of missing dates |
Shifts a date by a number of days
>>> shiftdate("20140606", 10)
"20140616"
Parameters: |
|
---|---|
Returns: | string representation of shifted date |
Shifts a list of dates
Same API as shiftdate, except it operates on an iterable of date strings.
>>> # Shift a list of dates forward 10 days
>>> shiftdate(["20140606", "20150301"], 10)
["20140616", "20150311"]
Parameters: |
|
---|---|
Returns: | list of shifted date strings |
See also
Selects indices which satisfy an interval condition
Chooses dates which lie in the interval [start, end).
Parameters: |
|
---|---|
Option endpoint: | |
flag to include end point in window |
|
Returns: | slice(istart, iend) |
Maps datetime.strptime onto iterable of strings
Parameters: |
|
---|---|
Returns: | list of datetime.datetime objects |