Changeset 448 for cybozu2ical/trunk/lib

Show
Ignore:
Timestamp:
10/16/07 22:14:17 (15 months ago)
Author:
ogawa
Message:

Move rrule handling code to WWW::CybozuOffice?6::Calendar for better factoring.
Update version numbers.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cybozu2ical/trunk/lib/WWW/CybozuOffice6/Calendar.pm

    r447 r448  
    1111use Text::CSV_XS; 
    1212 
    13 our $VERSION = '0.03'; 
     13our $VERSION = '0.20'; 
    1414 
    1515sub new { 
     
    223223@WWW::CybozuOffice6::Calendar::RecurrentEvent::ISA = qw( WWW::CybozuOffice6::Calendar::Event ); 
    224224 
     225sub rrule               { shift->_accessor('rrule',             @_) } 
     226# for compatibility 
    225227sub frequency           { shift->_accessor('frequency',         @_) } 
    226228sub frequency_value     { shift->_accessor('frequency_value',   @_) } 
     
    244246    return unless $freq && exists $FREQUENCY{$freq}; 
    245247 
    246     $this->{frequency} = $FREQUENCY{$freq}; 
    247     $this->{frequency_value} = $param{freq_value} || 0; 
     248    # rrule 
     249    my %rrule = (); 
     250    if ($FREQUENCY{$freq} eq 'WEEKDAYS') { 
     251        %rrule = ( FREQ => 'WEEKLY', BYDAY => 'MO,TU,WE,TH,FR' ); 
     252    } else { 
     253        %rrule = ( FREQ => $FREQUENCY{$freq} ); 
     254    } 
     255    if ($param{freq_value} =~ /^\d(SU|MO|TU|WE|TH|FR|SA)$/) { 
     256        $rrule{BYDAY} = $param{freq_value}; 
     257        $rrule{INTERVAL} = 1; 
     258    } 
    248259 
    249260    # until 
     
    257268            $until->set_time_zone('UTC'); # timezone must be UTC 
    258269        } 
    259         $this->{until} = $until; 
    260     } 
     270        $rrule{UNTIL} = $until; 
     271    } 
     272 
     273    $this->{rrule} = \%rrule; 
    261274 
    262275    # exdates 
     
    269282    } 
    270283 
     284    # for compatibility 
     285    $this->{frequency}       = $FREQUENCY{$freq}; 
     286    $this->{frequency_value} = $param{freq_value} || 0; 
     287    $this->{until}           = $rrule{UNTIL} if exists $rrule{UNTIL}; 
     288 
    271289    1; 
    272290} 
     
    418436Modified date of the item, or current timestamp.  DateTime object. 
    419437 
    420 =item frequency (string) 
     438=item rrule (HASHREF of rrule properties) 
     439 
     440Assocative list of recurrence rules for the item, which is *roughly* 
     441based on iCalendar Specification (RFC 2445). 
     442 
     443=item exdates (ARRAYREF of DateTime objects) 
     444 
     445Excluded dates of the reccurent item.  If the item has no excluded 
     446dates, this should be "undefined". 
     447 
     448=item [obsolete] frequency (string) 
    421449 
    422450Frequency mode of the recurrent item.  Each recurrent items has one 
     
    425453  "YEARLY", "MONTHLY", "WEEKLY", "DAILY", "WEEKDAYS" 
    426454 
    427 =item frequency_value (integer) 
     455=item [obsolete] frequency_value (integer) 
    428456 
    429457Frequency value of the recurrent item. 
    430458 
    431 =item until (DateTime object) 
     459=item [obsolete] until (DateTime object) 
    432460 
    433461End date of the recurrence for the recurrent item.  If the recurrence 
    434462continues infinitely, thie value should be "undefined". 
    435463 
    436 =item exdates (Array of DateTime objects) 
    437  
    438 Excluded dates of the reccurent item.  If the item has no excluded 
    439 dates, this should be "undefined". 
    440  
    441464=back 
    442465