delorean icon indicating copy to clipboard operation
delorean copied to clipboard

Get Range for Specific Interval

Open chriscannon opened this issue 11 years ago • 3 comments

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.

chriscannon avatar Jul 15 '13 19:07 chriscannon

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)

myusuf3 avatar Jul 15 '13 19:07 myusuf3

Sorry this is difficult to explain. My question really can be broken down into two questions:

  1. Can Delorean return date ranges as opposed to just a specific time instant?
  2. If the answer to #1 is yes, can Delorean return various date range lengths between a given start and stop date?

chriscannon avatar Jul 15 '13 19:07 chriscannon

  1. yes
  2. yes

Look at the code and link I pasted above.

myusuf3 avatar Jul 15 '13 20:07 myusuf3