Net::ICal::Time package represents a time and date in Icalendar.
$t = Net::ICal::Time->new( epoch => time );
$t = Net::ICal::Time->new( ical => '19970101' );
$t = Net::ICal::Time->new( ical => '19970101T120000',
timezone => 'America/Los_Angeles' );
# Eventually ...
$t = Net::ICal::Time-new( iso => '1997-10-14' );
# or other time formats ...
# Not yet implemented
$t = Net::ICal::Time->new(
second => 12,
minute => 5,
hour => 6,
day => 10,
month => 9,
year => 1997,
# Not yet implemented
$t2 = $t->add( hour => '6' );
This is ALPHA QUALITY CODE. Due to a roundoff error in Date::ICal, which it's based on, addition and subtraction is often one second off. Patches welcome. See the README that came with this module for how you can help.
Time represents a time, but can also hold the time zone for the time and indicate if the time should be treated as a date. The time can be constructed from a variey of formats.
Creates a new time object given one of:
epoch => integer seconds past the POSIX epoch.
ical => iCalendar date-time string
If neither of these arguments is supplied, the value will default to the current date.
WARNING: Timezone handling is currently in flux in Net::ICal, pending Date::ICal awareness of timezones. This may change the call syntax slightly.
use Net::ICal::Time; my $t1 = new Net::ICal::Time(ical => '20010402');
ok(defined($t1), 'simple iCal creation test (date only)');
print $t1->as_ical . "n";
# note: there *should* be a Z on the end of the string, because we assume # that new dates are in UTC unless otherwise specified. ok($t1->as_ical eq ':20010402Z', 'simple iCal creation (date only) makes correct iCal');
# TODO: define more tests in this vein that are Net::ICal specific. # Mostly, you want the tests here to be Date::ICal tests; # Don't just add tests here unless they test something specific to N::I.
Create a new copy of this time.
Accessor to the timezone. Takes & Returns an Olsen place name ("America/Los_Angeles", etc. ) , an Abbreviation, 'UTC', or 'float' if no zone was specified.
THIS IS NOT YET IMPLEMENTED. Date::ICal does not yet support timezones.
Takes a duration string or Duration and returns a Time that is the sum of the time and the duration. Does not modify this time.
Subtract out a time of type Time and return a Duration. Does not modify this time.
Change the time to what it would be in the named timezone. The zone can be an Olsen placename or "UTC".
THIS FUNCTION IS NOT YET IMPLEMENTED. We're waiting on Date::ICal to provide this function.
}; =end testing
Convert to an iCal format property string.
Convert to list format, as per localtime(). This is *not* timezone safe.
Convert to list format, as per gmtime()
Return 0-6 representing day of week of this date.
Return 1-365 representing day of year of this date.
Return the day of year of the first day (Sunday) of the week that this date is in