Implement Durations #4

jmalloc opened this Issue Jan 21, 2013 · 3 comments

1 participant

Icecave Studios member

The definitions here are appropriate:

  • interval - A span of time between two concrete points in the time-continuum.
  • duration - A measurement in seconds.
  • period - Duration defined in terms of individual components ("1 month, 3 days, 5 hours")

I'm not sure whether a duration is strictly necessary (we could just use a period and only use the seconds component), this requires further discussion.

Icecave Studios member

There's also the idea of a recurring period or duration with an interval, there should be an iterator for this... something like ...

$interval = new Year(2012);
$period = new Period('2 weeks');
$iterator = new PeriodIterator($interval, $period);

foreach ($iterator as $value)
    // $value would be an Interval containing each fortnightly chunk of the year 2012.
Icecave Studios member

Decided not to conflate Period and Duration instances, as you will always be able to get concrete seconds from a duration, but not necessarily a period.

@jmalloc jmalloc added a commit that referenced this issue May 6, 2013
@jmalloc jmalloc Added Duration class (#4) 4910a77
Icecave Studios member

Implementation of periods moved to #32.

@jmalloc jmalloc closed this in 3b5a424 May 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment