Changeset 518 for cybozu2ical/trunk/lib/WWW
- Timestamp:
- 09/01/08 19:33:58 (4 months ago)
- Location:
- cybozu2ical/trunk/lib/WWW/CybozuOffice6
- Files:
-
- 4 modified
-
Calendar/Event.pm (modified) (3 diffs)
-
Calendar/RecurrentEvent.pm (modified) (4 diffs)
-
CalendarDriver/ApiCalendar.pm (modified) (2 diffs)
-
CalendarDriver/SyncCalendar.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cybozu2ical/trunk/lib/WWW/CybozuOffice6/Calendar/Event.pm
r505 r518 19 19 20 20 __PACKAGE__->mk_accessors( 21 qw( id start end summary description created modified is_full_day comment )21 qw( id start end summary description created time_zone modified is_full_day comment ) 22 22 ); 23 23 … … 25 25 my ( $this, %param ) = @_; 26 26 27 $this-> {id} = $param{id} || '0';28 $this-> {time_zone} = $param{time_zone} || 'Asia/Tokyo';27 $this->id( $param{id} || '0' ); 28 $this->time_zone( $param{time_zone} || 'Asia/Tokyo' ); 29 29 30 my $start = $this->to_datetime( $param{s tart_date}, $param{start_time} );31 my $end = $this->to_datetime( $param{end_date}, $param{end_time} );30 my $start = $this->to_datetime( $param{set_date}, $param{set_time} ); 31 my $end = $this->to_datetime( $param{end_date}, $param{end_time} ); 32 32 return unless $start && $end; 33 33 34 # (s tart_time == empty) => A full-day event35 # (s tart_time != empty) && (end_time == empty) => A malformed event36 if ( $param{s tart_time} eq ':' ) {34 # (set_time == empty) => A full-day event 35 # (set_time != empty) && (end_time == empty) => A malformed event 36 if ( $param{set_time} eq ':' ) { 37 37 $start = $start->truncate( to => 'day' ); 38 38 $end = $end->add( days => 1 )->truncate( to => 'day' ); 39 $this-> {is_full_day} = 1;39 $this->is_full_day(1); 40 40 } 41 41 elsif ( $param{end_time} eq ':' ) { 42 42 $end = $start->clone->add( minutes => 10 ); 43 43 } 44 $this-> {start} = $start;45 $this-> {end} = $end;44 $this->start($start); 45 $this->end($end); 46 46 47 $this->{created} = DateTime->from_epoch( epoch => $param{created} || 0 ); 47 $param{timestamp} =~ s/^ts\.//; # remove rubbish 48 $this->created( DateTime->from_epoch( epoch => $param{timestamp} || 0 ) ); 48 49 49 50 my $summary = 50 ( $param{ abbrev} ? $param{abbrev} . ': ' : '' ) . $param{summary};51 $this-> {summary} = $summary;52 $this-> {description} = $param{description} || $summary;51 ( $param{event} ? $param{event} . ': ' : '' ) . $param{detail}; 52 $this->summary($summary); 53 $this->description( $param{memo} || $summary ); 53 54 1; 54 55 } … … 75 76 } 76 77 77 $args{time_zone} = $this-> {time_zone};78 $args{time_zone} = $this->time_zone; 78 79 79 80 DateTime->new(%args); -
cybozu2ical/trunk/lib/WWW/CybozuOffice6/Calendar/RecurrentEvent.pm
r505 r518 23 23 n => 'WEEKDAYS' 24 24 ); 25 our @WEEK_STRING = ( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); 25 26 26 27 sub parse { … … 28 29 $this->SUPER::parse(%param); 29 30 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]$/; 33 38 34 39 # rrule 35 40 my %rrule = (); 36 if ( $FREQUENCY{$ freq} eq 'WEEKDAYS' ) {41 if ( $FREQUENCY{$type} eq 'WEEKDAYS' ) { 37 42 %rrule = ( FREQ => 'WEEKLY', BYDAY => 'MO,TU,WE,TH,FR' ); 38 43 } 39 44 else { 40 %rrule = ( FREQ => $FREQUENCY{$ freq} );45 %rrule = ( FREQ => $FREQUENCY{$type} ); 41 46 } 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; 44 49 $rrule{INTERVAL} = 1; 45 50 } … … 51 56 my %args = ( year => $1, month => $2, day => $3 ); 52 57 my $until; 53 if ( $this-> {is_full_day}) {58 if ( $this->is_full_day ) { 54 59 $until = $this->to_datetime( $param{until_date}, ':' ); 55 60 } 56 61 else { 57 $until = $this-> {end}->clone->set(%args);62 $until = $this->end->clone->set(%args); 58 63 $until->set_time_zone('UTC'); # timezone must be UTC 59 64 } … … 61 66 } 62 67 63 $this-> {rrule} = \%rrule;68 $this->rrule( \%rrule ); 64 69 65 70 # exdates 66 if ( defined $param{ex dates} ) {71 if ( defined $param{exception} ) { 67 72 my @exdates; 68 for ( @{ $param{ex dates} } ) {69 push @exdates, $this->to_datetime( $_, $param{s tart_time} );73 for ( @{ $param{exception} } ) { 74 push @exdates, $this->to_datetime( $_, $param{set_time} ); 70 75 } 71 $this-> {exdates} = \@exdates;76 $this->exdates( \@exdates ); 72 77 } 73 78 74 79 # 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}; 78 83 79 84 1; -
cybozu2ical/trunk/lib/WWW/CybozuOffice6/CalendarDriver/ApiCalendar.pm
r515 r518 86 86 my $num_fields = @fields - 1; 87 87 next if $num_fields < 14; 88 $fields[1] =~ s/^ts\.//; # remove rubbish89 88 90 89 # Cybozu Calendar CSV Format … … 107 106 my %param; 108 107 @param{ 109 qw(id created freq freq_value start_date end_date start_time end_time abbrev summary description)108 qw(id timestamp type day set_date end_date set_time end_time event detail memo) 110 109 } = @fields[ 0, 1, 4, 5, 8 .. 11, 12 .. 14 ]; 111 110 112 111 $param{time_zone} = $cal->{time_zone} || 'Asia/Tokyo'; 113 112 113 if ( $num_fields > 14 ) { 114 my @exception = @fields[ 14 .. $num_fields ]; 115 $param{exception} = \@exception; 116 } 117 114 118 my $item; 115 if ( !$param{ freq} ) {119 if ( !$param{type} ) { 116 120 $item = WWW::CybozuOffice6::Calendar::Event->new(%param); 117 121 } 118 122 else { 119 123 @param{qw(end_date until_date)} = @fields[ 8, 9 ]; 120 if ( $num_fields > 14 ) {121 my @exdates = @fields[ 14 .. $num_fields ];122 $param{exdates} = \@exdates;123 }124 my $freq = $param{freq};125 if ( $freq =~ /^[1-5]$/ ) {126 $param{freq} = 'm';127 my @week_str = ( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' );128 $param{freq_value} = $freq . $week_str[ $param{freq_value} ];129 }130 124 $item = WWW::CybozuOffice6::Calendar::RecurrentEvent->new(%param); 131 125 } -
cybozu2ical/trunk/lib/WWW/CybozuOffice6/CalendarDriver/SyncCalendar.pm
r515 r518 50 50 my $num_fields = @fields - 1; 51 51 next if $num_fields < 13; 52 $fields[1] =~ s/^ts\.//; # remove rubbish53 52 54 53 # Cybozu Calendar CSV Format 55 54 # GENERIC | RECCURENT 56 # [ 0] id? | id?57 # [ 1] created | created55 # [ 0] ID 56 # [ 1] TimeStamp 58 57 # [ 2] <BLANK> x start_date / end_date 59 # [ 3] start_datex initial start_date?60 # [ 4] end_datex until_date61 # [ 5] start_time | start_time62 # [ 6] end_time | end_time63 # [ 7] <BLANK> | freq64 # [ 8] <BLANK> | freq_value65 # [ 9] ??? | ???66 # [10] ??? | ???67 # [11] abbrev | abbrev68 # [12] summary | summary69 # [13] description | description58 # [ 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 70 69 71 70 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) 74 72 } = @fields[ 0, 1, 5 .. 8, 11 .. 13 ]; 73 75 74 $param{time_zone} = $cal->{time_zone} || 'Asia/Tokyo'; 76 75 76 if ( $num_fields > 14 ) { 77 my @exception = @fields[ 14 .. $num_fields ]; 78 $param{exception} = \@exception; 79 } 80 77 81 my $item; 78 if ( !$param{ freq} ) {79 @param{qw(s tart_date end_date)} = @fields[ 3, 4 ];82 if ( !$param{type} ) { 83 @param{qw(set_date end_date)} = @fields[ 3, 4 ]; 80 84 $item = WWW::CybozuOffice6::Calendar::Event->new(%param); 81 85 } 82 86 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 ]; 94 88 $item = WWW::CybozuOffice6::Calendar::RecurrentEvent->new(%param); 95 89 }
![(please configure the [header_logo] section in trac.ini)](/public/chrome/common/trac_banner.png)