| 1 | #!/usr/bin/perl -w | ||
| 2 | # vi:sts=4:shiftwidth=4 | ||
| 3 | # -*- Mode: perl -*- | ||
| 4 | #====================================================================== | ||
| 5 | # | ||
| 6 | # This package is free software and is provided "as is" without | ||
| 7 | # express or implied warranty. It may be used, redistributed and/or | ||
| 8 | # modified under the same terms as perl itself. ( Either the Artistic | ||
| 9 | # License or the GPL. ) | ||
| 10 | # | ||
| 11 | # $Id: Daylight.pm,v 1.3 2001/08/04 05:43:32 srl Exp $ | ||
| 12 | # | ||
| 13 | # (C) COPYRIGHT 2000-2001, Reefknot developers. | ||
| 14 | # | ||
| 15 | # See the AUTHORS file included in the distribution for a full list. | ||
| 16 | #====================================================================== | ||
| 17 | |||
| 18 | =head1 NAME | ||
| 19 | |||
| 20 | Net::ICal::Daylight -- class for representing DAYLIGHT timezone sections | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | package Net::ICal::Daylight; | ||
| 25 | use strict; | ||
| 26 | |||
| 27 | use base qw(Net::ICal::Standard); | ||
| 28 | |||
| 29 | use Carp; | ||
| 30 | use Net::ICal::Property; | ||
| 31 | use Net::ICal::Util qw(:all); | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | This module represents a DAYLIGHT section in a VTIMEZONE, which | ||
| 36 | details information about when a particular timezone is on | ||
| 37 | daylight savings time. It includes information about when the | ||
| 38 | switch back to standard time happens. | ||
| 39 | |||
| 40 | =head1 SYNOPSIS | ||
| 41 | |||
| 42 | # really, look at Timezone.pm for a better usage example; | ||
| 43 | # this is totally untested | ||
| 44 | |||
| 45 | my $s = Net::ICal::Daylight->new( | ||
| 46 | tzoffsetto => '-0400', | ||
| 47 | tzoffsetfrom => '-0500', | ||
| 48 | rdate => Net::ICal::Recurrence->new ( ...) | ||
| 49 | tzname => 'EDT' | ||
| 50 | ); | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | =head1 METHODS | ||
| 55 | |||
| 56 | =head2 new(%args) | ||
| 57 | |||
| 58 | Makes a new Daylight object. For permissible parameters, see | ||
| 59 | Net::ICal::Standard. | ||
| 60 | |||
| 61 | =begin testing | ||
| 62 | |||
| 63 | TODO: { | ||
| 64 | local $TODO = "write tests here"; | ||
| 65 | ok(0, "write tests here, please"); | ||
| 66 | }; | ||
| 67 | |||
| 68 | =end testing | ||
| 69 | =head2 new_from_ical ($text) | ||
| 70 | |||
| 71 | Takes iCalendar text as a parameter; returns a Net::ICal::Daylight object. | ||
| 72 | |||
| 73 | =cut | ||
| 74 | |||
| 75 | # THIS IS INHERITED FROM Net::ICal::Component | ||
| 76 | |||
| 77 | #================================================================================== | ||
| 78 | # make sure that this object has the bare minimum requirements specified by the RFC | ||
| 79 | |||
| 80 | =head1 INTERNAL METHODS ONLY | ||
| 81 | |||
| 82 | Use these outside this module at your own peril. | ||
| 83 | |||
| 84 | =head2 validate($self) | ||
| 85 | |||
| 86 | This routine validates the creation arguments we were given | ||
| 87 | to make sure that we have all the necessary elements to create | ||
| 88 | a valid VDAYLIGHT. | ||
| 89 | =cut | ||
| 90 | |||
| 91 | =head2 create($class, %args) | ||
| 92 | |||
| 93 | This is an internal function that sets up the object. | ||
| 94 | It mainly establishes a Class::MethodMapper data map | ||
| 95 | and hands off creation of the object to Net::ICal::Component. | ||
| 96 | |||
| 97 | =cut | ||
| 98 | sub _create { | ||
| 99 | my ($class, %args) = @_; | ||
| 100 | |||
| 101 | # ugh. I hate to replicate this whole thing just for the | ||
| 102 | # one line of difference at the end of the sub. | ||
| 103 | # I know there's a better way to do this. Patches welcome. | ||
| 104 | |||
| 105 | my $map = { # RFC2445 4.6.5 describes VTIMEZONE | ||
| 106 | dtstart => { # RFC2445 4.6.5? - optional in VTIMEZONE, | ||
| 107 | type => 'parameter', | ||
| 108 | doc => '', | ||
| 109 | domain => 'ref', | ||
| 110 | # TODO, BUG 424114: needs to be in UTC. how to enforce? | ||
| 111 | options => 'Net::ICal::Time', | ||
| 112 | value => undef, | ||
| 113 | }, | ||
| 114 | tzoffsetto => { # RFC2445 4.8.3.4 - optional in VTIMEZONE | ||
| 115 | type => 'parameter', | ||
| 116 | doc => 'UTC offset in use now in this timezone', | ||
| 117 | domain => 'param', | ||
| 118 | options => [], | ||
| 119 | value => undef, | ||
| 120 | }, | ||
| 121 | tzoffsetfrom => { # RFC2445 4.8.3.3 - optional in VTIMEZONE | ||
| 122 | type => 'parameter', | ||
| 123 | doc => 'UTC offset in use prior to the current offset in this tz', | ||
| 124 | domain => 'param', | ||
| 125 | options => [], | ||
| 126 | value => undef, | ||
| 127 | }, | ||
| 128 | rdate => { # RFC2445 ? - optional multiple times in VTIMEZONE | ||
| 129 | # TODO: this should point to another N::I data type | ||
| 130 | type => 'parameter', | ||
| 131 | doc => 'recurrence date', | ||
| 132 | domain => 'ref', | ||
| 133 | options => 'ARRAY', | ||
| 134 | value => undef, | ||
| 135 | }, | ||
| 136 | rrule => { # RFC2445 ? - optional multiple times in VTIMEZONE | ||
| 137 | # TODO: this should point to another N::I data type | ||
| 138 | type => 'parameter', | ||
| 139 | doc => 'a recurrence rule', | ||
| 140 | domain => 'ref', | ||
| 141 | options => 'ARRAY', | ||
| 142 | value => undef, | ||
| 143 | }, | ||
| 144 | tzname => { # RFC2445 4.8.3.2 - optional multiple times in VTIMEZONE | ||
| 145 | type => 'parameter', | ||
| 146 | doc => 'a name for this timezone', | ||
| 147 | domain => 'param', | ||
| 148 | options => [], | ||
| 149 | value => undef, | ||
| 150 | }, | ||
| 151 | # FIXME: handle x-properties. | ||
| 152 | }; | ||
| 153 | |||
| 154 | # NOTE NOTE NOTE: the following line is the only | ||
| 155 | # substantial difference between Daylight and Standard. | ||
| 156 | # We do want to refactor this. Patches welcome. | ||
| 157 | my $self = Net::ICal::Component->new ('DAYLIGHT', $map, %args); | ||
| 158 | |||
| 159 | return $self; | ||
| 160 | } | ||
| 161 | |||
| 162 | 1; | ||
| 163 | |||
| 164 | =head1 SEE ALSO | ||
| 165 | |||
| 166 | More documentation pointers can be found in L<Net::ICal::Timezone> | ||
| 167 | and L<Net::ICal::Standard>. | ||
| 168 | |||
| 169 | =cut |