delorean
delorean copied to clipboard
Get Range for Specific Interval
Is there a way with Delorean stops to return date intervals between a start and stop date? For example, if I set start date to 2013-06-01 and end date to 2013-06-08 and I'd like the stop to return a date range of 7 days it should return the date range 2013-06-01 to 2013-06-07 and then just the single date of 2013-06-08.
http://delorean.readthedocs.org/en/latest/quickstart.html#with-power-comes
If I understand you correct something like ths?
>>> import delorean
>>> from delorean import stops
>>> from datetime import datetime
>>> d1 = datetime(2012, 5, 06)
>>> d2 = datetime(2013, 5, 06)
>>> for stop in stops(freq=delorean.DAILY, count=10, timezone="US/Eastern", start=d1, stop=d2): print stop
...
Delorean(datetime=2012-05-06 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-07 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-08 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-09 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-10 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-11 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-12 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-13 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-14 00:00:00-04:00, timezone=US/Eastern)
Delorean(datetime=2012-05-15 00:00:00-04:00, timezone=US/Eastern)
Sorry this is difficult to explain. My question really can be broken down into two questions:
- Can Delorean return date ranges as opposed to just a specific time instant?
- If the answer to #1 is yes, can Delorean return various date range lengths between a given start and stop date?
- yes
- yes
Look at the code and link I pasted above.