Event Modules

Dave Rolsky edited this page Jan 30, 2017 · 3 revisions

A module belongs under the DateTime::Event namespace if it calculates occurrences of events, such as holidays, eclipses, asteroids smashing into the earth and rendering it a lifeless hell, etc.

Returning DateTimes

Modules that calculate events should return results using the same class, time zone and locale as the argument:

$dt2 = $eclipse->next($dt1);

The easiest way to implement this is to calculate a DateTime::Duration, and then return datetime argument + duration, but make sure not to modify the datetime object given to this method. Using the clone() method makes this easier.

Note that if you feed a floating time to a module that makes calculations using UTC, the result will be a floating time that is only valid in the UTC time zone. Most astronomical calculations are in this category, such as sunrise, sunset, and moon position.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.