NAME
Date::Gregorian::Exact - timestamp precision extension for Date::Gregorian
SYNOPSIS
use Date::Gregorian::Exact;
$date =
Date::Gregorian::Exact->new->set_ymd(1999, 12, 31)->set_hms(23, 59, 59);
($hr, $min, $sec) = $date->get_hms;
if ($date->check_ymdhms($year, $month, $day, $hour, $min, $sec)) {
# valid, $date has new value
}
else {
# not valid, $date keeps old value
}
$delta = $date->get_seconds_since($otherdate);
$date->add_seconds($delta);
$date->set_localtime($time);
$time = $date->get_localtime;
DESCRIPTION
Date::Gregorian::Exact is a subclass extending Date::Gregorian towards higher precision (sufficient to deal with timestamps).
With Date::Gregorian::Exact objects, all methods of the base class Date::Gregorian work exactly as described there, except where noted below. In particular, most parameters must still be integer values.
Exceptions to this rule are add_days and get_days_since, now handling fractions of days as well as whole days, and set/get_gmtime, now no longer mapping any daytime to midnight.
Additional Methods
set/get_hms access hours, minutes and seconds. Non-integer values of seconds are allowed but not recommended, as they might introduce rounding errors.
check_ymdhms checks and, if valid, sets an exact date.
add_seconds and get_seconds_since handle time intervals much like add_days and get_days_since, only on a finer scale.
set/get_localtime convert timestamps as they would be interpreted in the current locale. This means, local timezone and daylight saving mode are taken into account like the localtime Perl function does.
Note, however, that timezones and daylight saving settings are not (yet) part of this module's data model. Any arithmetic done on these date objects assumes an ideal calendar with days of a uniform length of 24 hours. Guess why astronomers don't like daylight saving time either.
AUTHOR
Martin Hasch <martin@mathematik.uni-ulm.de>, November 1999.