| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Acme::PM::Paris::Meetings; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 352293 | use warnings; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 83 |  | 
| 4 | 2 |  |  | 2 |  | 14 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 73 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 2 |  |  | 2 |  | 2403 | use DateTime::Format::ICal; | 
|  | 2 |  |  |  |  | 802899 |  | 
|  | 2 |  |  |  |  | 87 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 2 |  |  | 2 |  | 27 | use Exporter 'import'; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 579 |  | 
| 9 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | 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 |  |  |  |  |  |  | { | 
| 60 | 1 | 50 |  | 1 | 1 | 46765 | my $dtstart = @_ | 
| 61 |  |  |  |  |  |  | ? $_[0] | 
| 62 |  |  |  |  |  |  | : DateTime->now(time_zone => 'Europe/Paris', | 
| 63 |  |  |  |  |  |  | locale => 'fr_FR') | 
| 64 |  |  |  |  |  |  | ->truncate(to => 'day'); | 
| 65 | 1 |  |  |  |  | 6 | 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 |  |  |  |  |  |  | my $iterator; | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | sub next_meeting | 
| 84 |  |  |  |  |  |  | { | 
| 85 | 0 |  | 0 | 0 | 1 | 0 | my $count = shift(@_) || -1; | 
| 86 |  |  |  |  |  |  |  | 
| 87 | 0 | 0 |  |  |  | 0 | unless (defined $iterator) { | 
| 88 | 0 |  |  |  |  | 0 | $iterator = recurrence()->iterator; | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 | 0 | 0 | 0 |  |  | 0 | if (wantarray && $count >= 1) { | 
| 92 | 0 |  |  |  |  | 0 | map { $iterator->next()->strftime("%A %d/%m/%Y %Hh%M") } 1..$count; | 
|  | 0 |  |  |  |  | 0 |  | 
| 93 |  |  |  |  |  |  | } else { | 
| 94 | 0 |  |  |  |  | 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 |  |  |  |  |  |  | sub ical { | 
| 106 | 1 |  |  | 1 | 1 | 14 | 'FREQ=MONTHLY;BYDAY=2WE;BYHOUR=20;BYMINUTE=0;BYSECOND=0' | 
| 107 |  |  |  |  |  |  | } | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | 1; # End of Acme::PM::Paris::Meetings | 
| 111 |  |  |  |  |  |  | __END__ |