| 1 | package DateTime::Format::ICal; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use vars qw ($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | $VERSION = '0.09'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use DateTime::Span; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use DateTime::Event::ICal; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use Params::Validate qw( validate_with SCALAR ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | return bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # key is string length | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | my %valid_formats = | |||||||||||||||||||||||||||||||||||||||||
| 24 | ( 15 => | ||||||||||||||||||||||||||||||||||||||||||
| 25 | { params => [ qw( year month day hour minute second ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 26 | regex => qr/^(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)$/, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 => | ||||||||||||||||||||||||||||||||||||||||||
| 29 | { params => [ qw( year month day hour minute ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 30 | regex => qr/^(\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)$/, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 11 => | ||||||||||||||||||||||||||||||||||||||||||
| 33 | { params => [ qw( year month day hour ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 34 | regex => qr/^(\d\d\d\d)(\d\d)(\d\d)T(\d\d)$/, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 8 => | ||||||||||||||||||||||||||||||||||||||||||
| 37 | { params => [ qw( year month day ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 38 | regex => qr/^(\d\d\d\d)(\d\d)(\d\d)$/, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | sub parse_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_datetime: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 22 | my ( $self, $date ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # save for error messages | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 22 | my $original = $date; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 22 | my %p; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 22 | ▶ | if ( $date =~ s/^TZID=([^:]+):// ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | $p{time_zone} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # Z at end means UTC | ||||||||||||||||||||||||||||||||||||||||||
| 55 | elsif ( $date =~ s/Z$// ) | ||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | $p{time_zone} = 'UTC'; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | else | ||||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | $p{time_zone} = 'floating'; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 22 | ▶ | my $format = $valid_formats{ length $date } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | or die "Invalid iCal datetime string ($original)\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 22 | @p{ @{ $format->{params} } } = $date =~ /$format->{regex}/; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 22 | return DateTime->new(%p); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub parse_duration | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_duration: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 11 | my ( $self, $dur ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 11 | my @units = qw( weeks days hours minutes seconds ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 11 | $dur =~ m{ ([\+\-])? # Sign | |||||||||||||||||||||||||||||||||||||||||
| 79 | P # 'P' for period? This is our magic character) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 81 | (?:(\d+)W)? # Weeks | ||||||||||||||||||||||||||||||||||||||||||
| 82 | (?:(\d+)D)? # Days | ||||||||||||||||||||||||||||||||||||||||||
| 83 | )? | ||||||||||||||||||||||||||||||||||||||||||
| 84 | (?: T # Time prefix | ||||||||||||||||||||||||||||||||||||||||||
| 85 | (?:(\d+)H)? # Hours | ||||||||||||||||||||||||||||||||||||||||||
| 86 | (?:(\d+)M)? # Minutes | ||||||||||||||||||||||||||||||||||||||||||
| 87 | (?:(\d+)S)? # Seconds | ||||||||||||||||||||||||||||||||||||||||||
| 88 | )? | ||||||||||||||||||||||||||||||||||||||||||
| 89 | }x; | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 11 | my $sign = $1; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 11 | my %units; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 11 | ▶ | $units{weeks} = $2 if defined $2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 11 | ▶ | $units{days} = $3 if defined $3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 11 | ▶ | $units{hours} = $4 if defined $4; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 11 | ▶ | $units{minutes} = $5 if defined $5; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 11 | ▶ | $units{seconds} = $6 if defined $6; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 11 | ▶ | die "Invalid ICal duration string ($dur)\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | unless %units; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 10 | ▶ | if ( defined $sign && $sign eq '-' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $sign and $sign eq "-"
MC/DC100%2/2
defined $sign and $sign eq "-"
defined $sign
$sign eq "-"
Truth table100%3/3
A and B
A= defined $signB= $sign eq "-"
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # $_ *= -1 foreach values %units; - does not work in 5.00503 | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | $units{$_} *= -1 foreach keys %units; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | return DateTime::Duration->new(%units); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | sub parse_period | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_period: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | my ( $self, $period ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | my ( $start, $end ) = $period =~ /^((?:TZID=[^:]+:)?.*?)\/(.*)/; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | die "Invalid ICal period string ($period)\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$start and $end
MC/DC0%0/2
$start and $end
$start
$end
Truth table33%1/3
A and B
A= $startB= $end
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | unless $start && $end; | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | $start = $self->parse_datetime( $start ); | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | ▶ | if ( $end =~ /[\+\-]P/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | $end = $start + $self->parse_duration( $end ); | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | else | ||||||||||||||||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | $end = $self->parse_datetime( $end ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | ▶ | die "Invalid ICal period: end before start ($period)\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | if $start > $end; | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | return DateTime::Span->new( start => $start, end => $end ); | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | sub parse_recurrence | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_recurrence: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | my %p = validate_with( params => \@_, | |||||||||||||||||||||||||||||||||||||||||
| 141 | spec => { recurrence => { type => SCALAR } }, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | allow_extra => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | my $recurrence = delete $p{recurrence}; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | # recurrence may start with RRULE: | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | $recurrence =~ s/^(?:RRULE|EXRULE)://i; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # parser: adapted from code written for Date::Set by jesse | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # RRULEs look like 'FREQ=foo;INTERVAL=bar;' etc. | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | foreach ( split /;/, $recurrence ) | |||||||||||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 13 | my ( $name, $value ) = split /=/; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 13 | $name = lc $name; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | # BY<FOO> parameters should be arrays. everything else should be strings | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 13 | ▶ | if ( $name eq 'until' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | $p{$name} = __PACKAGE__->parse_datetime( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | elsif ( $name =~ /^by/i ) | ||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | $p{$name} = [ split /,/, lc( $value ) ]; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | else | ||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | $p{$name} = lc( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | return DateTime::Event::ICal->recur(%p); | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | sub format_datetime | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 30 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_datetime: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 30 | my ( $self, $dt ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 30 | my $tz = $dt->time_zone; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 30 | ▶ | unless ( $tz->is_floating || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$tz->is_floating or $tz->is_utc or $tz->is_olson
$tz->is_floating or $tz->is_utc
MC/DC100%3/3
$tz->is_floating or $tz->is_utc or $tz->is_olson
$tz->is_floating
$tz->is_utc
$tz->is_olson
Truth table100%4/4
A or B or C
A= $tz->is_floatingB= $tz->is_utcC= $tz->is_olson
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | $tz->is_utc || | ||||||||||||||||||||||||||||||||||||||||||
| 184 | $tz->is_olson ) | ||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | $dt = $dt->clone->set_time_zone('UTC'); | |||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | $tz = $dt->time_zone; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 30 | my $base = | |||||||||||||||||||||||||||||||||||||||||
| 191 | sprintf( '%04d%02d%02dT%02d%02d%02d', | ||||||||||||||||||||||||||||||||||||||||||
| 192 | $dt->year, $dt->month, $dt->day, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | $dt->hour, $dt->minute, $dt->second ); | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 30 | ▶ | return $base if $tz->is_floating; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 17 | ▶ | return $base . 'Z' if $tz->is_utc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | return 'TZID=' . $tz->name . ':' . $base; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | sub format_duration | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_duration: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 11 | my ( $self, $duration ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 11 | ▶ | die "Cannot represent years or months in an iCal duration\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | if $duration->delta_months; | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | # simple string for 0-length durations | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | ▶ | return '+PT0S' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$duration->delta_days or $duration->delta_minutes or $duration->delta_seconds
$duration->delta_days or $duration->delta_minutes
MC/DC100%3/3
$duration->delta_days or $duration->delta_minutes or $duration->delta_seconds
$duration->delta_days
$duration->delta_minutes
$duration->delta_seconds
Truth table100%4/4
A or B or C
A= $duration->delta_daysB= $duration->delta_minutesC= $duration->delta_seconds
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | unless $duration->delta_days || | ||||||||||||||||||||||||||||||||||||||||||
| 212 | $duration->delta_minutes || | ||||||||||||||||||||||||||||||||||||||||||
| 213 | $duration->delta_seconds; | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 10 | ▶ | my $ical = $duration->is_positive ? '+' : '-'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 10 | $ical .= 'P'; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 10 | ▶ | if ( $duration->delta_days ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | ▶ | $ical .= $duration->weeks . 'W' if $duration->weeks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | ▶ | $ical .= $duration->days . 'D' if $duration->days; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 10 | ▶ | if ( $duration->delta_minutes || $duration->delta_seconds ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$duration->delta_minutes or $duration->delta_seconds
MC/DC100%2/2
$duration->delta_minutes or $duration->delta_seconds
$duration->delta_minutes
$duration->delta_seconds
Truth table100%3/3
A or B
A= $duration->delta_minutesB= $duration->delta_seconds
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 8 | $ical .= 'T'; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 | ▶ | $ical .= $duration->hours . 'H' if $duration->hours; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 8 | ▶ | $ical .= $duration->minutes . 'M' if $duration->minutes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 8 | ▶ | $ical .= $duration->seconds . 'S' if $duration->seconds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 10 | return $ical; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | sub format_period | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_period: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 3 | my ( $self, $span ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | return $self->format_datetime( $span->start ) . '/' . | |||||||||||||||||||||||||||||||||||||||||
| 242 | $self->format_datetime( $span->end ) ; | ||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | sub format_period_with_duration | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_period_with_duration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | my ( $self, $span ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | return $self->format_datetime( $span->start ) . '/' . | |||||||||||||||||||||||||||||||||||||||||
| 250 | $self->format_duration( $span->duration ) ; | ||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | sub _split_datetime_tz | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_datetime_tz: called CC=9 SCAR=24.4
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 16 | my ( $self, $dt ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 16 | my $tz = $dt->time_zone; | |||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 16 | ▶ | unless ( $tz->is_floating || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$tz->is_floating or $tz->is_utc or $tz->is_olson
$tz->is_floating or $tz->is_utc
MC/DC0%0/3
$tz->is_floating or $tz->is_utc or $tz->is_olson
$tz->is_floating
$tz->is_utc
$tz->is_olson
Truth table75%3/4
A or B or C
A= $tz->is_floatingB= $tz->is_utcC= $tz->is_olson
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | $tz->is_utc || | ||||||||||||||||||||||||||||||||||||||||||
| 262 | $tz->is_olson ) | ||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $dt = $dt->clone->set_time_zone('UTC'); | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $tz = $dt->time_zone; | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 16 | ▶ | my $base = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$dt->hour or $dt->min or $dt->sec
$dt->hour or $dt->min
MC/DC0%0/3
$dt->hour or $dt->min or $dt->sec
$dt->hour
$dt->min
$dt->sec
Truth table25%1/4
A or B or C
A= $dt->hourB= $dt->minC= $dt->sec
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | ( $dt->hour || $dt->min || $dt->sec ? | ||||||||||||||||||||||||||||||||||||||||||
| 270 | sprintf( '%04d%02d%02dT%02d%02d%02d', | ||||||||||||||||||||||||||||||||||||||||||
| 271 | $dt->year, $dt->month, $dt->day, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | $dt->hour, $dt->minute, $dt->second ) : | ||||||||||||||||||||||||||||||||||||||||||
| 273 | sprintf( '%04d%02d%02d', $dt->year, $dt->month, $dt->day ) | ||||||||||||||||||||||||||||||||||||||||||
| 274 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 16 | ▶ | return ($base, '') if $tz->is_floating; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | ▶ | return ($base, 'UTC') if $tz->is_utc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | return ($base, $tz->name); | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | sub format_recurrence | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_recurrence: called CC=34 SCAR=37.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 22 | my ( $self, $set, @more ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 22 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | # normalize param to either DT::Set or DT::SpanSet | ||||||||||||||||||||||||||||||||||||||||||
| 287 | # DT list => convert to DT::Set | ||||||||||||||||||||||||||||||||||||||||||
| 288 | # DT::Span list => convert to DT::SpanSet | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 22 | ▶ | if ( $set->isa('DateTime') ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 10 | $set = DateTime::Set->from_datetimes( dates => [ $set, @more ] ); | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif ( $set->isa('DateTime::Span') ) | ||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $set = DateTime::SpanSet->from_spans( spans => [ $set, @more ] ); | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | # is it a recurrence? | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 22 | ▶ | if ( $set->{set}->is_too_complex ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # DT::Set recurrence => DTSTART;timezone:date CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # RRULE:params CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 304 | # note: add more lines if necessary: | ||||||||||||||||||||||||||||||||||||||||||
| 305 | # union = more RRULE/RDATE lines | ||||||||||||||||||||||||||||||||||||||||||
| 306 | # complement = more EXRULE/EXDATE lines | ||||||||||||||||||||||||||||||||||||||||||
| 307 | # intersection = ? | ||||||||||||||||||||||||||||||||||||||||||
| 308 | # note: timezone is specified by DTSTART only. | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | # TODO: add support to DT::Event::Recurrence objects | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 10 | ▶ | if ( $set->can( 'get_ical' ) && defined $set->get_ical ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$set->can("get_ical") and defined $set->get_ical
MC/DC100%2/2
$set->can("get_ical") and defined $set->get_ical
$set->can("get_ical")
defined $set->get_ical
Truth table100%3/3
A and B
A= $set->can("get_ical")B= defined $set->get_ical
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 8 | my %ical = $set->get_ical; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 8 | for ( @{ $ical{include} } ) | |||||||||||||||||||||||||||||||||||||||||
| 316 | { | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 19 | ▶ | next unless $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 19 | ▶ | if ( ref( $_ ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | { | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 6 | push @result, $self->format_recurrence( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | else | ||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 13 | push @result, $_; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 8 | ▶ | if ( $ical{exclude} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | my @exclude; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 3 | for ( @{ $ical{exclude} } ) | |||||||||||||||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | ▶ | next unless $_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 4 | ▶ | if ( ref( $_ ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | push @exclude, $self->format_recurrence( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | else | ||||||||||||||||||||||||||||||||||||||||||
| 338 | { | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | push @exclude, $_; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | s/^RDATE/EXDATE/ for @exclude; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 3 | s/^RRULE/EXRULE/ for @exclude; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | push @result, @exclude; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | else | ||||||||||||||||||||||||||||||||||||||||||
| 348 | { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | die "format_recurrence() - Format not implemented for this unbounded set"; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | # end: format recurrence | ||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | else | ||||||||||||||||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | # DT::Set => RDATE:datetime,datetime,datetime CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 357 | # DT::SpanSet => RDATE;VALUE=PERIOD:period,period CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 358 | # | ||||||||||||||||||||||||||||||||||||||||||
| 359 | # not supported => RDATE;VALUE=DATE:date,date,date CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 360 | # | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # DT::Set w/tz => RDATE;timezone:date,date CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 362 | # DT::SpanSet w/tz => RDATE;VALUE=PERIOD;timezone:period,period CRLF | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 12 | my $iterator = $set->iterator; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 12 | my $last_type = 'DateTime'; | |||||||||||||||||||||||||||||||||||||||||
| 366 | 12 | my $last_tz = 'invalid'; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 12 | my $item; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 12 | ▶ | while( $item = $iterator->next ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 16 | ▶ | if( $item->isa('DateTime') ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 14 | my ($base,$tz) = $self->_split_datetime_tz( $item ); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 14 | ▶ | if( $last_tz eq $tz && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$last_tz eq $tz and $last_type eq "DateTime"
MC/DC50%1/2
$last_tz eq $tz and $last_type eq "DateTime"
$last_tz eq $tz
$last_type eq "DateTime"
Truth table66%2/3
A and B
A= $last_tz eq $tzB= $last_type eq "DateTime"
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | $last_type eq 'DateTime' ) | ||||||||||||||||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | $result[-1] .= ',' . $base; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | ▶ | $result[-1] .= 'Z' if $tz eq 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | else | ||||||||||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 13 | push @result, 'RDATE'; | |||||||||||||||||||||||||||||||||||||||||
| 383 | 13 | ▶ | $result[-1] .= ';TZID='.$tz if $tz ne '' && $tz ne 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tz ne "" and $tz ne "UTC"
MC/DC100%2/2
$tz ne "" and $tz ne "UTC"
$tz ne ""
$tz ne "UTC"
Truth table100%3/3
A and B
A= $tz ne ""B= $tz ne "UTC"
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 13 | $result[-1] .= ':' . $base; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 13 | ▶ | $result[-1] .= 'Z' if $tz eq 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 13 | $last_tz = $tz; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 13 | $last_type = 'DateTime'; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | elsif( $item->isa('DateTime::Span') ) | ||||||||||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 2 | my $item_start = $item->start; | |||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | my $item_end = $item->end; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | ▶ | if ( $item_start == $item_end ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | { | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | $item = $item_start; | |||||||||||||||||||||||||||||||||||||||||
| 397 | # item looks like a datetime | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | redo; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | my ($start,$tz) = $self->_split_datetime_tz( $item_start ); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | $item_end->set_time_zone( $tz ); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | my ($end,undef) = $self->_split_datetime_tz( $item_end ); | |||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | ▶ | if( $last_tz eq $tz && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$last_tz eq $tz and $last_type eq "DateTime::Span"
MC/DC0%0/2
$last_tz eq $tz and $last_type eq "DateTime::Span"
$last_tz eq $tz
$last_type eq "DateTime::Span"
Truth table33%1/3
A and B
A= $last_tz eq $tzB= $last_type eq "DateTime::Span"
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | $last_type eq 'DateTime::Span' ) | ||||||||||||||||||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $result[-1] .= ',' . $start; | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | $result[-1] .= 'Z' if $tz eq 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $result[-1] .= '/' . $end; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | $result[-1] .= 'Z' if $tz eq 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | else | ||||||||||||||||||||||||||||||||||||||||||
| 412 | { | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | push @result, 'RDATE;VALUE=PERIOD'; | |||||||||||||||||||||||||||||||||||||||||
| 414 | 1 | ▶ | $result[-1] .= ';TZID='.$tz if $tz ne '' && $tz ne 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tz ne "" and $tz ne "UTC"
MC/DC0%0/2
$tz ne "" and $tz ne "UTC"
$tz ne ""
$tz ne "UTC"
Truth table33%1/3
A and B
A= $tz ne ""B= $tz ne "UTC"
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 1 | $result[-1] .= ':' . $start; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | $result[-1] .= 'Z' if $tz eq 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | $result[-1] .= '/' . $end; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | $result[-1] .= 'Z' if $tz eq 'UTC'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | $last_tz = $tz; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | $last_type = 'DateTime::Span'; | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | else | ||||||||||||||||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | die 'unexpected data type "'.ref($item).'" in set'; | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | # end: format list of dates | ||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 20 | ▶ | return join( "\n", @result ) if ! wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 20 | return @result; | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | __END__ | ||||||||||||||||||||||||||||||||||||||||||