Changeset 374
- Timestamp:
- 06/15/07 20:02:37 (18 months ago)
- Location:
- cybozu2ical/trunk
- Files:
-
- 2 modified
-
cybozu2ical (modified) (3 diffs)
-
lib/WWW/CybozuOffice6/Calendar.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cybozu2ical/trunk/cybozu2ical
r372 r374 20 20 our $VERSION = '0.12'; 21 21 22 ### TRICK (stop escaping for 'exdate' property) 23 *Data::ICal::Property::_value_as_string = sub { 24 my $self = shift; 25 my $key = shift; 26 my $value = defined($self->value()) ? $self->value() : ''; 27 28 unless ($self->vcal10) { 29 my $lc_key = lc($key); 30 $value =~ s/\\/\\/gs; 31 $value =~ s/\Q;/\\;/gs unless ($lc_key eq 'rrule' || $lc_key eq 'exdate'); 32 $value =~ s/,/\\,/gs unless ($lc_key eq 'rrule' || $lc_key eq 'exdate'); 33 $value =~ s/\n/\\n/gs; 34 $value =~ s/\\N/\\N/gs; 35 } 36 37 return $value; 38 39 }; 40 ### END 41 22 42 my %opt = (conf => 'config.yaml'); 23 43 GetOptions(\%opt, 'help', 'debug', 'conf=s') or pod2usage(2); … … 60 80 # handle frequency 61 81 if ($item->can('frequency')) { 82 # rrule 62 83 my $freq = $item->frequency; 63 84 my %rrules = $freq ne 'WEEKDAYS' ? … … 67 88 if $item->until; 68 89 $args{rrule} = join ';', map { $_ . '=' . $rrules{$_} } keys %rrules; 90 91 # exdate 92 # $args{exdate} = join ',', map { to_icaldate($_, 1) } $item->exdates 93 # if $item->exdates; 94 if ($item->exdates) { 95 if ($item->is_full_day) { 96 $args{exdate} = [join(',', map { to_icaldate($_, 1) } $item->exdates), { VALUE => 'DATE' }]; 97 } else { 98 $args{exdate} = [join(',', map { to_icaldate($_, 0) } $item->exdates), { TZID => $time_zone }]; 99 } 100 } 101 69 102 } 70 103 -
cybozu2ical/trunk/lib/WWW/CybozuOffice6/Calendar.pm
r373 r374 52 52 or die 'Failed to parse CSV input'; 53 53 my @fields = $csv->fields; 54 next if $#fields < 13; # num. of fields 54 my $num_fields = @fields - 1; 55 next if $num_fields < 13; 55 56 $fields[1] =~ s/^ts\.//; # remove rubbish 56 57 … … 59 60 # [ 0] id? | id? 60 61 # [ 1] created | created 61 # [ 2] <BLANK> x start_date62 # [ 3] start_date x end_date62 # [ 2] <BLANK> x modified start_date 63 # [ 3] start_date x start_date / end_date 63 64 # [ 4] end_date x until_date 64 65 # [ 5] start_time | start_time … … 81 82 $item = WWW::CybozuOffice6::Calendar::Event->new(%param); 82 83 } else { 83 @param{qw(start_date end_date until_date)} = @fields[2..4]; 84 @param{qw(start_date end_date until_date)} = @fields[3,3,4]; 85 if ($num_fields > 13) { 86 my @exdates = @fields[14..$num_fields]; 87 $param{exdates} = \@exdates; 88 } 84 89 $item = WWW::CybozuOffice6::Calendar::RecurrentEvent->new(%param); 85 90 } … … 194 199 sub until { shift->_accessor('until', @_) } 195 200 201 sub exdates { 202 my $this = shift; 203 return unless $this->{exdates}; 204 my $dates = $this->{exdates}; 205 wantarray ? @$dates : @$dates[0]; 206 } 207 196 208 our %FREQUENCY = ( y => 'YEARLY', m => 'MONTHLY', w => 'WEEKLY', 197 209 d => 'DAILY', n => 'WEEKDAYS' ); … … 207 219 $this->{frequency_value} = $param{freq_value} || 0; 208 220 221 # until 209 222 if ($param{until_date} =~ m!^(\d+)/(\d+)/(\d+)$!) { 210 223 my %args = (year => $1, month => $2, day => $3); … … 218 231 $this->{until} = $until; 219 232 } 233 234 # exdates 235 if (defined $param{exdates}) { 236 my @dates; 237 for (@{$param{exdates}}) { 238 push @dates, $this->to_datetime($_, $param{start_time}); 239 } 240 $this->{exdates} = \@dates; 241 } 242 220 243 1; 221 244 }
![(please configure the [header_logo] section in trac.ini)](/public/chrome/common/trac_banner.png)