-
Notifications
You must be signed in to change notification settings - Fork 49
Event Modules
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.
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.