| 1 | package Langertha::Holmgang::Sim::Linux::Calendar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: systemd calendar expressions (OnCalendar) for the Linux simulator — check, normalise, next elapse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 82 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 82 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 82 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 82 | ▶ | use Time::Local (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 82 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 82 | my @WD = qw( Mon Tue Wed Thu Fri Sat Sun ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 82 | my %WD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 82 | for my $i ( 0 .. 6 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 574 | $WD{ lc $WD[$i] } = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 574 | $WD{ (qw( monday tuesday wednesday thursday friday saturday sunday ))[$i] } = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 82 | my %SHORT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | minutely => '*-*-* *:*:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | hourly => '*-*-* *:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | daily => '*-*-* 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | weekly => 'Mon *-*-* 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | monthly => '*-*-01 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | quarterly => '*-01,04,07,10-01 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | semiannually => '*-01,07-01 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | yearly => '*-01-01 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | annually => '*-01-01 00:00:00', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Zeitzone -> [ Normalzeit-Versatz in s, Regel (eu|us|undef), Abkuerzung normal, Sommer ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | our %ZONE = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # Abkuerzungen der Ortszeit nimmt systemd an (fester Versatz) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | CET => [ 3600, undef, 'CET' ], CEST => [ 7200, undef, 'CEST' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | UTC => [ 0, undef, 'UTC' ], GMT => [ 0, undef, 'GMT' ], 'Etc/UTC' => [ 0, undef, 'UTC' ], 'Etc/GMT' => [ 0, undef, 'GMT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1230 | ( map { ( "Europe/$_" => [ 3600, 'eu', 'CET', 'CEST' ] ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | qw( Berlin Vienna Zurich Paris Amsterdam Brussels Luxembourg Rome Madrid Copenhagen Oslo Stockholm Warsaw Prague Budapest ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 246 | ▶ | ( map { ( "Europe/$_" => [ 0, 'eu', $_ eq 'Lisbon' ? 'WET' : $_ eq 'Dublin' ? 'GMT' : 'GMT', $_ eq 'Lisbon' ? 'WEST' : $_ eq 'Dublin' ? 'IST' : 'BST' ] ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | qw( London Dublin Lisbon ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 82 | ( map { ( "Europe/$_" => [ 7200, 'eu', 'EET', 'EEST' ] ) } qw( Helsinki Athens Bucharest Sofia Riga Tallinn Vilnius ) ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 'America/New_York' => [ -18000, 'us', 'EST', 'EDT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 'America/Chicago' => [ -21600, 'us', 'CST', 'CDT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'America/Denver' => [ -25200, 'us', 'MST', 'MDT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'America/Los_Angeles' => [ -28800, 'us', 'PST', 'PDT' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'Asia/Tokyo' => [ 32400, undef, 'JST' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 'Asia/Singapore' => [ 28800, undef, '+08' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'Asia/Kolkata' => [ 19800, undef, 'IST' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 82 | our $LOCAL = 'Europe/Berlin'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # Ein Feld -> ( [ Werte ] oder undef fuer *, Text der Normalform ); () = ungueltig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 818 | ▶ | sub _field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_field: called CC=25 SCAR=33.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 818 | my ( $s, $min, $max, $width, $frac ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 818 | ▶ | return ( undef, '*' ) if $s eq '*'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 420 | ▶ | if ( $frac && $s =~ /\A(\d+)\.(\d{1,6})\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$frac and $s =~ /\A(\d+)\.(\d{1,6})\z/
MC/DC100%2/2
$frac and $s =~ /\A(\d+)\.(\d{1,6})\z/
$frac
$s =~ /\A(\d+)\.(\d{1,6})\z/
Truth table100%3/3
A and B
A= $fracB= $s =~ /\A(\d+)\.(\d{1,6})\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | return () if $1 > $max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | return ( [ 0 + $1 ], sprintf( "%0${width}d.%06d", $1, substr( $2 . '000000', 0, 6 ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 419 | my ( @v, @txt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 419 | for my $part ( split /,/, $s, -1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 426 | ▶ | my ( $a, $b, $step ) = $part =~ /\A(\*|\d+)(?:\.\.(\d+))?(?:\/(\d+))?\z/ or return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 426 | ▶ | return () if $a eq '*' && ( defined $b || !defined $step ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$a eq "*" and defined $b || !defined($step)
defined $b or not defined $step
MC/DC0%0/3
$a eq "*" and defined $b || !defined($step)
$a eq "*"
defined $b
not defined $step
Truth table25%1/4
A and B or not(C)
A= $a eq "*"B= defined $bC= not defined $step
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 426 | ▶ | my $lo = $a eq '*' ? $min : $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 426 | ▶ | my $hi = defined $b ? $b : defined $step ? $max : $lo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 426 | ▶ | return () if $lo < $min || $hi > $max || $lo > $hi || ( defined $step && $step == 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%8/12
$lo < $min or $hi > $max or $lo > $hi or defined $step and $step == 0
$lo < $min or $hi > $max or $lo > $hi
$lo < $min or $hi > $max
defined $step and $step == 0
MC/DC20%1/5
$lo < $min or $hi > $max or $lo > $hi or defined $step and $step == 0
$lo < $min
$hi > $max
$lo > $hi
defined $step
$step == 0
Truth table50%3/6
A or B or C or D and E
A= $lo < $minB= $hi > $maxC= $lo > $hiD= defined $stepE= $step == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 421 | ▶ | undef $step if defined $b && defined $step && $step == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $b and defined $step and $step == 1
defined $b and defined $step
MC/DC66%2/3
defined $b and defined $step and $step == 1
defined $b
defined $step
$step == 1
Truth table75%3/4
A and B and C
A= defined $bB= defined $stepC= $step == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 421 | ▶ | for ( my $i = $lo; $i <= $hi; $i += $step // 1 ) { push @v, 0 + $i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$step // 1
MC/DC100%1/1
$step // 1
$step
Truth table100%2/2
A
A= $step
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 421 | ▶ | my $f = sub { $_[0] eq '*' ? '*' : sprintf( "%0${width}d", $_[0] ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 421 | ▶ | push @txt, $f->($a) . ( defined $b ? '..' . $f->($b) : '' ) . ( defined $step ? '/' . $step : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 414 | my %u = map { $_ => 1 } @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 414 | return ( [ sort { $a <=> $b } keys %u ], join( ',', @txt ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Wochentage "Mon-Wed,Fri" -> ( [ 0..6 ] oder undef fuer alle, Normalform ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 60 | ▶ | sub _weekdays { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_weekdays: called CC=15 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 60 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 60 | my %on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 60 | for my $part ( split /,/, $s, -1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 85 | ▶ | my ( $a, $b ) = $part =~ /\A([A-Za-z]+)(?:(?:\.\.|-)([A-Za-z]+))?\z/ or return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 84 | ▶ | return () unless exists $WD{ lc $a } && ( !defined $b || exists $WD{ lc $b } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $WD{lc $a} and !defined($b) || exists $WD{lc $b}
not defined $b or exists $WD{lc $b}
MC/DC33%1/3
exists $WD{lc $a} and !defined($b) || exists $WD{lc $b}
exists $WD{lc $a}
not defined $b
exists $WD{lc $b}
Truth table75%3/4
A and not(B) or C
A= exists $WD{lc $a}B= not defined $bC= exists $WD{lc $b}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 72 | ▶ | my ( $x, $y ) = ( $WD{ lc $a }, defined $b ? $WD{ lc $b } : $WD{ lc $a } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 72 | ▶ | return () if $y < $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 69 | $on{$_} = 1 for $x .. $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 44 | my @d = sort { $a <=> $b } keys %on; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 44 | ▶ | return ( undef, undef ) if @d == 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 41 | my @txt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 41 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 41 | ▶ | while ( $i < @d ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 46 | my $j = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 46 | ▶ | $j++ while $j + 1 < @d && $d[ $j + 1 ] == $d[$j] + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$j + 1 < @d and $d[$j + 1] == $d[$j] + 1
MC/DC100%2/2
$j + 1 < @d and $d[$j + 1] == $d[$j] + 1
$j + 1 < @d
$d[$j + 1] == $d[$j] + 1
Truth table100%3/3
A and B
A= $j + 1 < @dB= $d[$j + 1] == $d[$j] + 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 46 | ▶ | if ( $j - $i >= 2 ) { push @txt, "$WD[$d[$i]]..$WD[$d[$j]]" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 22 | elsif ( $j == $i ) { push @txt, $WD[ $d[$i] ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 7 | else { push @txt, $WD[ $d[$i] ], $WD[ $d[$j] ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 46 | $i = $j + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 41 | return ( \@d, join( ',', @txt ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 171 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=42 SCAR=37.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 171 | my ($expr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 171 | ▶ | return undef unless defined $expr && $expr =~ /\A\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $expr and $expr =~ /\A\S/
MC/DC50%1/2
defined $expr and $expr =~ /\A\S/
defined $expr
$expr =~ /\A\S/
Truth table66%2/3
A and B
A= defined $exprB= $expr =~ /\A\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 169 | ( my $s = $expr ) =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 169 | my @w = split /\s+/, $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 169 | my $tz; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 169 | ▶ | if ( @w > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 121 | ▶ | my $z = lc( $w[-1] ) eq 'utc' ? 'UTC' : $w[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 121 | ▶ | if ( $ZONE{$z} ) { $tz = $z; pop @w } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 169 | ▶ | if ( @w == 1 && exists $SHORT{ lc $w[0] } ) { @w = split / /, $SHORT{ lc $w[0] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@w == 1 and exists $SHORT{lc $w[0]}
MC/DC100%2/2
@w == 1 and exists $SHORT{lc $w[0]}
@w == 1
exists $SHORT{lc $w[0]}
Truth table100%3/3
A and B
A= @w == 1B= exists $SHORT{lc $w[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 169 | ▶ | my %c = ( tz => $tz, utc => defined $tz && !$ZONE{$tz}[0] && !$ZONE{$tz}[1] ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $tz and not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[0] and not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[1]
defined $tz and not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[0]
MC/DC66%2/3
defined $tz and not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[0] and not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[1]
defined $tz
not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[0]
not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[1]
Truth table75%3/4
A and not(B) and not(C)
A= defined $tzB= not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[0]C= not $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz}[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 169 | my @norm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 169 | ▶ | if ( @w && $w[0] =~ /\A[A-Za-z]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@w and $w[0] =~ /\A[A-Za-z]/
MC/DC50%1/2
@w and $w[0] =~ /\A[A-Za-z]/
@w
$w[0] =~ /\A[A-Za-z]/
Truth table66%2/3
A and B
A= @wB= $w[0] =~ /\A[A-Za-z]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 60 | ▶ | my ( $d, $t ) = _weekdays( shift @w ) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 44 | $c{wd} = $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 44 | ▶ | push @norm, $t if defined $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 153 | my ( $date, $time ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 153 | for my $x (@w) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 232 | ▶ | if ( !defined $date && !defined $time && $x !~ /:/ && $x =~ /[-~]/ ) { $date = $x } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%9/9
not defined $date || defined $time || $x =~ /:/ and $x =~ /[-~]/
defined $date || defined $time || $x =~ /:/
defined $date or defined $time
MC/DC100%4/4
not defined $date || defined $time || $x =~ /:/ and $x =~ /[-~]/
defined $date
defined $time
$x =~ /:/
$x =~ /[-~]/
Truth table100%5/5
not(A or B || C) and D
A= defined $dateB= defined $timeC= $x =~ /:/D= $x =~ /[-~]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 140 | ▶ | elsif ( !defined $time && $x =~ /:/ ) { $time = $x } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not defined $time and $x =~ /:/
MC/DC100%2/2
not defined $time and $x =~ /:/
not defined $time
$x =~ /:/
Truth table100%3/3
not(A) and B
A= not defined $timeB= $x =~ /:/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 13 | else { return undef } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 140 | ▶ | return undef if !defined $date && !defined $time && !exists $c{wd}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $date or defined $time or exists $c{"wd"}
defined $date or defined $time
MC/DC0%0/3
defined $date or defined $time or exists $c{"wd"}
defined $date
defined $time
exists $c{"wd"}
Truth table75%3/4
A or B or C
A= defined $dateB= defined $timeC= exists $c{"wd"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 140 | ▶ | $date //= '*-*-*'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$date //= "*-*-*"
MC/DC100%1/1
$date //= "*-*-*"
$date
Truth table100%2/2
A
A= $date
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 140 | ▶ | $time //= '00:00:00'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$time //= "00:00:00"
MC/DC100%1/1
$time //= "00:00:00"
$time
Truth table100%2/2
A
A= $time
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 140 | ▶ | my ( $ym, $sep, $day ) = $date =~ /\A(.*)([-~])([^-~]*)\z/ or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 140 | ▶ | $c{last} = $sep eq '~' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 140 | my @ymv = split /-/, $ym, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 140 | ▶ | unshift @ymv, '*' if @ymv == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 140 | ▶ | return undef unless @ymv == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 138 | ▶ | $ymv[0] = $ymv[0] + ( $ymv[0] < 70 ? 2000 : 1900 ) if $ymv[0] =~ /\A\d{2}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 138 | my @t = split /:/, $time, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 138 | ▶ | push @t, '00' if @t == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 138 | ▶ | return undef unless @t == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 138 | my @f = ( @ymv, $day, @t ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 138 | my @lim = ( [ 1970, 2199, 4 ], [ 1, 12, 2 ], [ 1, 31, 2 ], [ 0, 23, 2 ], [ 0, 59, 2 ], [ 0, 59, 2, 1 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 138 | my @txt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 138 | for my $i ( 0 .. 5 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 818 | ▶ | my ( $v, $tx ) = _field( $f[$i], @{ $lim[$i] } ) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 813 | $c{ (qw( year mon day hour min sec ))[$i] } = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 813 | push @txt, $tx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # ~T/n zaehlt vom Monatsende aus weiter zum Ende hin: ~07/1 = die letzten sieben Tage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 133 | ▶ | if ( $c{last} && $f[2] =~ /\A(\d+)\/(\d+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$c{"last"} and $f[2] =~ m[\A(\d+)/(\d+)\z]
MC/DC100%2/2
$c{"last"} and $f[2] =~ m[\A(\d+)/(\d+)\z]
$c{"last"}
$f[2] =~ m[\A(\d+)/(\d+)\z]
Truth table100%3/3
A and B
A= $c{"last"}B= $f[2] =~ m[\A(\d+)/(\d+)\z]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my @d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | for ( my $i = $1; $i >= 1; $i -= $2 ) { push @d, 0 + $i } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | $c{day} = [ sort { $a <=> $b } @d ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 133 | ▶ | push @norm, "$txt[0]-$txt[1]" . ( $c{last} ? '~' : '-' ) . $txt[2], join( ':', @txt[ 3 .. 5 ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 133 | ▶ | push @norm, $tz if defined $tz; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 133 | $c{normalized} = join ' ', @norm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 133 | return \%c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 218104 | ▶ | sub _last_sunday { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_last_sunday: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 218104 | my ( $y, $m ) = @_; # $m 0-basiert; Mitternacht UTC des letzten Sonntags | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 218104 | my $t = Time::Local::timegm( 0, 0, 0, _dim( $y, $m ), $m, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 218104 | return $t - ( gmtime $t )[6] * 86400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 10 | ▶ | sub _nth_sunday { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_nth_sunday: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 10 | my ( $y, $m, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 10 | my $t = Time::Local::timegm( 0, 0, 0, 1, $m, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 10 | my $wd = ( gmtime $t )[6]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 10 | return $t + ( ( 7 - $wd ) % 7 ) * 86400 + ( $n - 1 ) * 7 * 86400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 218150 | ▶ | sub _dim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dim: called CC=4 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 218150 | my ( $y, $m ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 218150 | ▶ | return ( 31, ( $y % 4 == 0 && ( $y % 100 != 0 || $y % 400 == 0 ) ) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )[$m]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$y % 4 == 0 and $y % 100 != 0 || $y % 400 == 0
$y % 100 != 0 or $y % 400 == 0
MC/DC0%0/3
$y % 4 == 0 and $y % 100 != 0 || $y % 400 == 0
$y % 4 == 0
$y % 100 != 0
$y % 400 == 0
Truth table25%1/4
A and B or C
A= $y % 4 == 0B= $y % 100 != 0C= $y % 400 == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 109168 | ▶ | sub offset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offset: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 109168 | my ( $t, $tz ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 109168 | ▶ | my ( $std, $rule ) = @{ $ZONE{ $tz // $LOCAL } || $ZONE{$LOCAL} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz // $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL} || $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
$tz // $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz // $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL} || $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz // $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
MC/DC0%0/2
$tz // $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL
$tz
$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL
Truth table33%1/3
A || B
A= $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$tz // $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}B= $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
Truth table66%2/3
A // B
A= $tzB= $Langertha::Holmgang::Sim::Linux::Calendar::LOCAL
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 109168 | ▶ | return $std unless $rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 109061 | my $y = ( gmtime $t )[5] + 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 109061 | ▶ | if ( $rule eq 'eu' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 109056 | ▶ | return $t >= _last_sunday( $y, 2 ) + 3600 && $t < _last_sunday( $y, 9 ) + 3600 ? $std + 3600 : $std; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$t >= _last_sunday($y, 2) + 3600 and $t < _last_sunday($y, 9) + 3600
MC/DC100%2/2
$t >= _last_sunday($y, 2) + 3600 and $t < _last_sunday($y, 9) + 3600
$t >= _last_sunday($y, 2) + 3600
$t < _last_sunday($y, 9) + 3600
Truth table100%3/3
A and B
A= $t >= _last_sunday($y, 2) + 3600B= $t < _last_sunday($y, 9) + 3600
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5 | my $from = _nth_sunday( $y, 2, 2 ) + 7200 - $std; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | my $to = _nth_sunday( $y, 10, 1 ) + 7200 - ( $std + 3600 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | ▶ | return $t >= $from && $t < $to ? $std + 3600 : $std; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t >= $from and $t < $to
MC/DC0%0/2
$t >= $from and $t < $to
$t >= $from
$t < $to
Truth table33%1/3
A and B
A= $t >= $fromB= $t < $to
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 110 | ▶ | sub next_elapse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_elapse: called CC=20 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 110 | my ( $c, $after ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 110 | my $tz = $c->{tz}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 110 | my ( undef, undef, undef, $d0, $m0, $y0 ) = gmtime( $after + offset( $after, $tz ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 110 | my $day = Time::Local::timegm( 0, 0, 0, $d0, $m0, $y0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 110 | ▶ | my %in = map { my $k = $_; ( $k => $c->{$k} ? { map { $_ => 1 } @{ $c->{$k} } } : undef ) } qw( year mon day ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 110 | ▶ | my $wd = $c->{wd} ? { map { $_ => 1 } @{ $c->{wd} } } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 110 | ▶ | my @hours = $c->{hour} ? @{ $c->{hour} } : 0 .. 23; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 110 | ▶ | my @mins = $c->{min} ? @{ $c->{min} } : 0 .. 59; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 110 | ▶ | my @secs = $c->{sec} ? @{ $c->{sec} } : 0 .. 59; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 110 | for my $n ( 0 .. 366 * 5 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2745 | my $d = $day + $n * 86400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2745 | my ( undef, undef, undef, $dd, $mm, $yy, $w ) = gmtime $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2745 | ▶ | next if $in{year} && !$in{year}{ $yy + 1900 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$in{"year"} and not $in{"year"}{$yy + 1900}
MC/DC100%2/2
$in{"year"} and not $in{"year"}{$yy + 1900}
$in{"year"}
not $in{"year"}{$yy + 1900}
Truth table100%3/3
A and not(B)
A= $in{"year"}B= not $in{"year"}{$yy + 1900}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 987 | ▶ | next if $in{mon} && !$in{mon}{ $mm + 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$in{"mon"} and not $in{"mon"}{$mm + 1}
MC/DC100%2/2
$in{"mon"} and not $in{"mon"}{$mm + 1}
$in{"mon"}
not $in{"mon"}{$mm + 1}
Truth table100%3/3
A and not(B)
A= $in{"mon"}B= not $in{"mon"}{$mm + 1}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 427 | ▶ | next if $in{day} && !$in{day}{ $c->{last} ? _dim( $yy + 1900, $mm ) - $dd + 1 : $dd }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$in{"day"} and not $in{"day"}{$$c{"last"} ? _dim($yy + 1900, $mm) - $dd + 1 : $dd}
MC/DC100%2/2
$in{"day"} and not $in{"day"}{$$c{"last"} ? _dim($yy + 1900, $mm) - $dd + 1 : $dd}
$in{"day"}
not $in{"day"}{$$c{"last"} ? _dim($yy + 1900, $mm) - $dd + 1 : $dd}
Truth table100%3/3
A and not(B)
A= $in{"day"}B= not $in{"day"}{$$c{"last"} ? _dim($yy + 1900, $mm) - $dd + 1 : $dd}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 278 | ▶ | next if $wd && !$wd->{ ( $w + 6 ) % 7 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$wd and not $$wd{($w + 6) % 7}
MC/DC100%2/2
$wd and not $$wd{($w + 6) % 7}
$wd
not $$wd{($w + 6) % 7}
Truth table100%3/3
A and not(B)
A= $wdB= not $$wd{($w + 6) % 7}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 170 | for my $h (@hours) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 338 | for my $mi (@mins) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3820 | for my $s (@secs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 54222 | my $lt = $d + $h * 3600 + $mi * 60 + $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 54222 | my $t = $lt - offset( $lt - offset( $lt, $tz ), $tz ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 54222 | ▶ | return $t if $t > $after; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 162 | ▶ | sub format_local { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_local: called CC=8 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 162 | my ( $t, $zone ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 162 | ▶ | $zone = !defined $zone || $zone eq '0' || $zone eq '' ? $LOCAL : $zone eq '1' ? 'UTC' : $zone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
not defined $zone or $zone eq 0 or $zone eq ""
not defined $zone or $zone eq 0
MC/DC33%1/3
not defined $zone or $zone eq 0 or $zone eq ""
not defined $zone
$zone eq 0
$zone eq ""
Truth table50%2/4
not(A) or B or C
A= not defined $zoneB= $zone eq 0C= $zone eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 162 | ▶ | my $z = $ZONE{$zone} || $ZONE{$LOCAL}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$zone} || $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$zone} || $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$zone}
$Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
Truth table33%1/3
A || B
A= $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$zone}B= $Langertha::Holmgang::Sim::Linux::Calendar::ZONE{$Langertha::Holmgang::Sim::Linux::Calendar::LOCAL}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 162 | my $off = offset( $t, $zone ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 162 | my @g = gmtime( $t + $off ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 162 | ▶ | my $abbr = $off != $z->[0] && defined $z->[3] ? $z->[3] : $z->[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$off != $$z[0] and defined $$z[3]
MC/DC50%1/2
$off != $$z[0] and defined $$z[3]
$off != $$z[0]
defined $$z[3]
Truth table66%2/3
A and B
A= $off != $$z[0]B= defined $$z[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 162 | return sprintf '%s %04d-%02d-%02d %02d:%02d:%02d %s', $WD[ ( $g[6] + 6 ) % 7 ], $g[5] + 1900, $g[4] + 1, $g[3], $g[2], $g[1], $g[0], $abbr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 17 | ▶ | sub left { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
left: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 17 | ▶ | return '0s' if $s <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 17 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 17 | my $d = int( $s / 86400 ); $s -= $d * 86400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 17 | my $h = int( $s / 3600 ); $s -= $h * 3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 17 | my $m = int( $s / 60 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 17 | ▶ | push @p, $d == 1 ? '1 day' : "$d days" if $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 17 | ▶ | push @p, "${h}h" if $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 17 | ▶ | push @p, "${m}min" if $m && !$d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$m and not $d
MC/DC100%2/2
$m and not $d
$m
not $d
Truth table100%3/3
A and not(B)
A= $mB= not $d
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 17 | ▶ | return @p ? join( ' ', @p ) : int($s) . 's'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 82 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||