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/CalendarDriver/SyncCalendar.pm

    r515 r518  
    5050        my $num_fields = @fields - 1; 
    5151        next if $num_fields < 13; 
    52         $fields[1] =~ s/^ts\.//;    # remove rubbish 
    5352 
    5453        # Cybozu Calendar CSV Format 
    5554        #      GENERIC     | RECCURENT 
    56         # [ 0] id?         | id? 
    57         # [ 1] created     | created 
     55        # [ 0] ID 
     56        # [ 1] TimeStamp 
    5857        # [ 2] <BLANK>     x start_date / end_date 
    59         # [ 3] start_date  x initial start_date? 
    60         # [ 4] end_date    x until_date 
    61         # [ 5] start_time  | start_time 
    62         # [ 6] end_time    | end_time 
    63         # [ 7] <BLANK>     | freq 
    64         # [ 8] <BLANK>     | freq_value 
    65         # [ 9] ???         | ??? 
    66         # [10] ???         | ??? 
    67         # [11] abbrev      | abbrev 
    68         # [12] summary     | summary 
    69         # [13] description | description 
     58        # [ 3] SetDate     x initial start_date? 
     59        # [ 4] EndDate     x until_date 
     60        # [ 5] SetTime 
     61        # [ 6] Endtime 
     62        # [ 7] <BLANK>     | TypeOmit 
     63        # [ 8] <BLANK>     | Day 
     64        # [ 9] Private 
     65        # [10] Banner 
     66        # [11] Event 
     67        # [12] Detail 
     68        # [13] Memo 
    7069 
    7170        my %param; 
    72         @param{ 
    73             qw(id created start_time end_time freq freq_value abbrev summary description) 
     71        @param{ qw(id timestamp set_time end_time type day event detail memo) 
    7472          } = @fields[ 0, 1, 5 .. 8, 11 .. 13 ]; 
     73 
    7574        $param{time_zone} = $cal->{time_zone} || 'Asia/Tokyo'; 
    7675 
     76        if ( $num_fields > 14 ) { 
     77            my @exception = @fields[ 14 .. $num_fields ]; 
     78            $param{exception} = \@exception; 
     79        } 
     80 
    7781        my $item; 
    78         if ( !$param{freq} ) { 
    79             @param{qw(start_date end_date)} = @fields[ 3, 4 ]; 
     82        if ( !$param{type} ) { 
     83            @param{qw(set_date end_date)} = @fields[ 3, 4 ]; 
    8084            $item = WWW::CybozuOffice6::Calendar::Event->new(%param); 
    8185        } 
    8286        else { 
    83             @param{qw(start_date end_date until_date)} = @fields[ 2, 2, 4 ]; 
    84             if ( $num_fields > 13 ) { 
    85                 my @exdates = @fields[ 14 .. $num_fields ]; 
    86                 $param{exdates} = \@exdates; 
    87             } 
    88             my $freq = $param{freq}; 
    89             if ( $freq =~ /^[1-5]$/ ) { 
    90                 $param{freq} = 'm'; 
    91                 my @week_str = ( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); 
    92                 $param{freq_value} = $freq . $week_str[ $param{freq_value} ]; 
    93             } 
     87            @param{qw(set_date end_date until_date)} = @fields[ 2, 2, 4 ]; 
    9488            $item = WWW::CybozuOffice6::Calendar::RecurrentEvent->new(%param); 
    9589        }