Show
Ignore:
Timestamp:
09/01/08 19:33:58 (4 months ago)
Author:
ogawa
Message:

Use accessors instead of directly accessing object fields.
Modify Event constructors' parameters so as to be subjected to Cybozu scripting.

Files:
1 modified

Legend:

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

    r505 r518  
    2323    n => 'WEEKDAYS' 
    2424); 
     25our @WEEK_STRING = ( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); 
    2526 
    2627sub parse { 
     
    2829    $this->SUPER::parse(%param); 
    2930 
    30     # frequency 
    31     my $freq = $param{freq}; 
    32     return unless $freq && exists $FREQUENCY{$freq}; 
     31    my ( $type, $day ) = ( $param{type}, $param{day} ); 
     32    return 
     33      unless defined $type 
     34          && ( $type =~ /^[1-5]$/ || exists $FREQUENCY{$type} ); 
     35 
     36    ( $type, $day ) = ( 'm', $type . $WEEK_STRING[$day] ) 
     37      if $type =~ /^[1-5]$/; 
    3338 
    3439    # rrule 
    3540    my %rrule = (); 
    36     if ( $FREQUENCY{$freq} eq 'WEEKDAYS' ) { 
     41    if ( $FREQUENCY{$type} eq 'WEEKDAYS' ) { 
    3742        %rrule = ( FREQ => 'WEEKLY', BYDAY => 'MO,TU,WE,TH,FR' ); 
    3843    } 
    3944    else { 
    40         %rrule = ( FREQ => $FREQUENCY{$freq} ); 
     45        %rrule = ( FREQ => $FREQUENCY{$type} ); 
    4146    } 
    42     if ( $param{freq_value} =~ /^\d(SU|MO|TU|WE|TH|FR|SA)$/ ) { 
    43         $rrule{BYDAY}    = $param{freq_value}; 
     47    if ( $param{day} =~ /^\d(SU|MO|TU|WE|TH|FR|SA)$/ ) { 
     48        $rrule{BYDAY}    = $day; 
    4449        $rrule{INTERVAL} = 1; 
    4550    } 
     
    5156        my %args = ( year => $1, month => $2, day => $3 ); 
    5257        my $until; 
    53         if ( $this->{is_full_day} ) { 
     58        if ( $this->is_full_day ) { 
    5459            $until = $this->to_datetime( $param{until_date}, ':' ); 
    5560        } 
    5661        else { 
    57             $until = $this->{end}->clone->set(%args); 
     62            $until = $this->end->clone->set(%args); 
    5863            $until->set_time_zone('UTC');    # timezone must be UTC 
    5964        } 
     
    6166    } 
    6267 
    63     $this->{rrule} = \%rrule; 
     68    $this->rrule( \%rrule ); 
    6469 
    6570    # exdates 
    66     if ( defined $param{exdates} ) { 
     71    if ( defined $param{exception} ) { 
    6772        my @exdates; 
    68         for ( @{ $param{exdates} } ) { 
    69             push @exdates, $this->to_datetime( $_, $param{start_time} ); 
     73        for ( @{ $param{exception} } ) { 
     74            push @exdates, $this->to_datetime( $_, $param{set_time} ); 
    7075        } 
    71         $this->{exdates} = \@exdates; 
     76        $this->exdates( \@exdates ); 
    7277    } 
    7378 
    7479    # for compatibility 
    75     $this->{frequency}       = $FREQUENCY{$freq}; 
    76     $this->{frequency_value} = $param{freq_value} || 0; 
    77     $this->{until}           = $rrule{UNTIL} if exists $rrule{UNTIL}; 
     80    $this->frequency( $FREQUENCY{$type} ); 
     81    $this->frequency_value( $day || 0 ); 
     82    $this->until( $rrule{UNTIL} ) if exists $rrule{UNTIL}; 
    7883 
    7984    1;