| 1 | package Acme::PM::Paris::Meetings; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use DateTime::Format::ICal; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | our @EXPORT = qw(next_meeting); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Acme::PM::Paris::Meetings - Get the date/time of the next Paris.pm meeting! | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 VERSION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Version 200905.04 | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION = '200905.04'; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | Using the 'paris-pm' script: | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | $ paris-pm -3 | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | One-liner: | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | perl -MAcme::PM::Paris::Meetings -e "print next_meeting" | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | Longer: | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | use DateTime; | ||||||||||||||||||||||||||||
| 38 | use Acme::PM::Paris::Meetings; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | my $rec = Acme::PM::Paris::Meetings::recurrence(); | ||||||||||||||||||||||||||||
| 41 | my $dt = $rec->iterator->next(DateTime->now(time_zone => 'Europe/Paris')); | ||||||||||||||||||||||||||||
| 42 | ... | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =cut | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head2 recurrence | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Returns a new DateTime::Set from which you can get the date/time of the planned | ||||||||||||||||||||||||||||
| 54 | Paris.pm meeting for the following months. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub recurrence | ||||||||||||||||||||||||||||
| 59 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
recurrence: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my $dtstart = @_ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | ? $_[0] | ||||||||||||||||||||||||||||
| 62 | : DateTime->now(time_zone => 'Europe/Paris', | ||||||||||||||||||||||||||||
| 63 | locale => 'fr_FR') | ||||||||||||||||||||||||||||
| 64 | ->truncate(to => 'day'); | ||||||||||||||||||||||||||||
| 65 | 1 | DateTime::Format::ICal->parse_recurrence( | |||||||||||||||||||||||||||
| 66 | recurrence => ical(), | ||||||||||||||||||||||||||||
| 67 | dtstart => $dtstart, | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head2 next_meeting | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Convenience function that returns the date/time of the next Paris.pm meeting | ||||||||||||||||||||||||||||
| 74 | as a string formatted for french humans. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | An internal recurrence object is maintained so if you call the method multiple times, | ||||||||||||||||||||||||||||
| 77 | you will get different results. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 3 | my $iterator; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub next_meeting | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
next_meeting: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my $count = shift(@_) || -1; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || -1
MC/DC0%0/1
shift @_ || -1
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | unless (defined $iterator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | $iterator = recurrence()->iterator; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (wantarray && $count >= 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
wantarray and $count >= 1
MC/DC0%0/2
wantarray and $count >= 1
wantarray
$count >= 1
Truth table0%0/3
A and B
A= wantarrayB= $count >= 1
| |||||||||||||||||||||||||||||
| 92 | 0 | map { $iterator->next()->strftime("%A %d/%m/%Y %Hh%M") } 1..$count; | |||||||||||||||||||||||||||
| 93 | } else { | ||||||||||||||||||||||||||||
| 94 | 0 | $iterator->next()->strftime("%A %d/%m/%Y %Hh%M") | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head2 ical | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | Returns the current ICal expression for the next Paris.pm meeting. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 1 | ▶ | sub ical { | ||||||||||||||||||||||||||
|
Subroutine
ical: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 106 | 1 | 'FREQ=MONTHLY;BYDAY=2WE;BYHOUR=20;BYMINUTE=0;BYSECOND=0' | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 3 | 1; # End of Acme::PM::Paris::Meetings | |||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||