Changeset 448

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

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cybozu2ical/trunk/cybozu2ical

    r447 r448  
    1717use Getopt::Long; 
    1818 
    19 our $VERSION = '0.13'; 
     19our $VERSION = '0.20'; 
    2020 
    2121### 
     
    149149 
    150150    # handle frequency 
    151     if ($item->can('frequency')) { 
     151    if ($item->can('rrule')) { 
    152152        # rrule 
    153         my $freq = $item->frequency; 
    154         my %rrules = $freq ne 'WEEKDAYS' ? 
    155             ( FREQ => $freq ) : 
    156             ( FREQ => 'WEEKLY', BYDAY => 'MO,TU,WE,TH,FR' ); 
    157         if ($item->frequency_value =~ /^\d(SU|MO|TU|WE|TH|FR|SA)$/) { 
    158             $rrules{BYDAY} = $item->frequency_value; 
    159             $rrules{INTERVAL} = 1; 
     153        my %rrule = %{$item->rrule}; 
     154        $rrule{UNTIL} = to_icaldate($rrule{UNTIL}, $item->is_full_day) 
     155            if $rrule{UNTIL}; 
     156        $rrule{WKST} = 'SU' 
     157            if $opt{'compat-google-calendar'}; 
     158 
     159        my @rrule_list; 
     160        for (qw(FREQ COUNT INTERVAL BYMONTH BYMONTHDAY WKST BYDAY UNTIL)) { 
     161            push @rrule_list, $_ . '=' . $rrule{$_} 
     162                if exists $rrule{$_}; 
    160163        } 
    161         $rrules{UNTIL} = to_icaldate($item->until, $item->is_full_day) 
    162             if $item->until; 
    163         $rrules{WKST} = 'SU' 
    164             if $opt{'compat-google-calendar'}; 
    165  
    166         my @rrules; 
    167         for (qw(FREQ COUNT INTERVAL BYMONTH BYMONTHDAY WKST BYDAY UNTIL)) { 
    168             push @rrules, $_ . '=' . $rrules{$_} 
    169                 if exists $rrules{$_}; 
    170         } 
    171         $args{rrule} = join ';', @rrules; 
     164        $args{rrule} = join ';', @rrule_list; 
    172165 
    173166        # exdate 
  • 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