Implement iterators. #3

Closed
jmalloc opened this Issue Jan 21, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Owner

jmalloc commented Jan 21, 2013

Implement the following iterators:

  • TimeSpanIterator($startTime, $timeSpan, $iterations = null) produces DateTime elements
  • IntervalIterator($interval, $timeSpan) produces DateTime elements
  • YearIterator($startTime, $iterations = null) produces Year elements
  • YearIntervalIterator($interval) produces Year elements
  • MonthIterator($startTime, $iterations = null) produces Month elements
  • MonthIntervalIterator($interval) produces Month elements
  • DayIterator($startTime, $iterations = null) produces Date elements
  • DayIntervalIterator($interval) produces Date elements
  • HourIterator($startTime, $iterations = null) produces DateTime elements
  • HourIntervalIterator($interval) produces DateTime elements
  • MinuteIterator($startTime, $iterations = null) produces DateTime elements
  • MinuteIntervalIterator($interval) produces DateTime elements
  • SecondIterator($startTime, $iterations = null) produces DateTime elements
  • SecondIntervalIterator($interval) produces DateTime elements

Each iterator has two variants, one which takes an interval and yields all distinct values within that interval, the other which takes a start time and a number of iterations (or null for infinite iterations).

Most iterators can probably be implemented in terms of the first two (TimeSpanIterator and IntervalIterator), but be aware that they are required to produce different element types.

koden-km added a commit to koden-km/chrono that referenced this issue May 14, 2013

Member

koden-km commented May 14, 2013

Made a minor change to current() methods (commit 6bdb517)

jmalloc added a commit that referenced this issue May 14, 2013

@ghost ghost assigned koden-km May 14, 2013

koden-km added a commit to koden-km/chrono that referenced this issue May 14, 2013

jmalloc added a commit that referenced this issue May 14, 2013

Merge pull request #51 from koden-km/feature/iterators-interval
Added interval iterator classes. (refs #3)
Owner

jmalloc commented May 14, 2013

Also add convenience methods to construct iterators from an interval:

  • Interval::byYear()
  • Interval::byMonth()
  • Interval::byDay()
  • Interval::byHour()
  • Interval::byMinute()
  • Interval::bySecond()
  • Interval::byTimeSpan(TimeSpanInterface $timeSpan)

@ghost ghost assigned jmalloc May 16, 2013

@jmalloc jmalloc closed this in 8eedf67 May 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment