Functions.pm

filter: Statementstmt 100% 157 / 157 Branchbran 95.1% 78 / 82 Conditioncond 98.2% 55 / 56 MC/DCmcdc 96.7% 30 / 31 Subroutinesub 100% 18 / 18 Podpod 100% 10 / 10 totaltotal 98.3% 348 / 354 SCAR 41.3
CC
62
Cov
98%
reformat_date
13.0
format_date
10.0
compare_dates
10.0
CRAP 62.0
↑ Summary List.pm »
1 package Calendar::Functions;
2  
3 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 $VERSION = '1.01';
8  
9 #----------------------------------------------------------------------------
10  
11 =head1 NAME
12  
13 Calendar::Functions - A module containing functions for dates and calendars.
14  
15 =head1 SYNOPSIS
16  
17 use Calendar::Functions;
18 $ext = ext($day);
19 $moty = moty($monthname);
20 $monthname = moty($moty);
21 $dotw = dotw($dayname);
22 $dayname = dotw($dotw);
23  
24 use Calendar::Functions qw(:dates);
25 my $dateobj = encode_date($day,$month,$year);
26 ($day,$month,$year,$dotw) = decode_date($dateobj);
27 $cmp = compare_dates($dateobj1, $dateobj2);
28  
29 use Calendar::Functions qw(:form);
30 $str = format_date( $fmt, $day, $month, $year, $dotw);
31 $str = reformat_date( $date, $fmt1, $fmt2 );
32  
33 use Calendar::Functions qw(:all);
34 fail_range($year);
35  
36 =head1 DESCRIPTION
37  
38 The module is intended to provide numerous support functions for other
39 date and/or calendar functions
40  
41 =head1 EXPORT
42  
43 ext, moty, dotw
44  
45 dates: encode_date, decode_date, compare_dates, add_day
46  
47 form: format_date, reformat_date
48  
49 all: encode_date, decode_date, compare_dates, add_day
50 format_date, reformat_date,
51 ext, moty, dotw, fail_range
52  
53 =cut
54  
55 #----------------------------------------------------------------------------
56  
57 #############################################################################
58 #Export Settings #
59 #############################################################################
60  
61 18 require Exporter;
62  
63 18 @ISA = qw(Exporter);
64  
65 18 %EXPORT_TAGS = (
66 'basic' => [ qw( ext moty dotw ) ],
67 'dates' => [ qw( ext moty dotw
68 encode_date decode_date compare_dates add_day ) ],
69 'form' => [ qw( ext moty dotw format_date reformat_date ) ],
70 'all' => [ qw( ext moty dotw format_date reformat_date fail_range
71 encode_date decode_date compare_dates add_day ) ],
72 'test' => [ qw( _caltest ) ],
73 );
74  
75 18 @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} }, @{ $EXPORT_TAGS{'test'} } );
76 18 @EXPORT = ( @{ $EXPORT_TAGS{'basic'} } );
77  
78 #############################################################################
79 #Library Modules #
80 #############################################################################
81  
82 18 ▶use Time::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
83 18 ▶eval "use Date::ICal";
Subroutine BEGIN: called CC=1 SCAR=0.0
84 18 my $di = ! $@;
85 18 ▶eval "use DateTime";
Subroutine BEGIN: called CC=1 SCAR=0.0
86 18 my $dt = ! $@;
87 18 ▶eval "use Time::Piece";
Subroutine BEGIN: called CC=1 SCAR=0.0
88 18 my $tp = ! $@;
89  
90 18 ▶if($tp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tp) 18 0 18
91 18 require Time::Piece;
92 }
93  
94 #############################################################################
95 #Variables
96 #############################################################################
97  
98 # prime our print out names
99 18 my @months = qw( NULL January February March April May June July
100 August September October November December );
101 18 my @dotw = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday );
102  
103 18 my $MinYear = 1902;
104 18 my $MaxYear = 2037;
105 18 my $EpoYear = 1970;
106  
107 #----------------------------------------------------------------------------
108  
109 #############################################################################
110 #Interface Functions #
111 #############################################################################
112  
113 =head1 FUNCTIONS
114  
115 =over 4
116  
117 =item encode_date( DD, MM, YYYY )
118  
119 Translates the given date values into a date object or number.
120  
121 =cut
122  
123 # name: encode_date
124 # args: day,month,year .... standard numerical day/month/year values
125 # retv: date object or number
126 # desc: Translates the given date values into a date object or number.
127  
128 sub encode_date {
129 597 ▶ my ($day,$mon,$year) = @_;
Subroutine encode_date: called CC=7 SCAR=19.5
Pod documented
130 597 my $this;
131  
132 597 ▶ if($day && $mon && $year) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day and $mon and $year) 575 22 597
Condition100%6/6
$day and $mon and $year
!ll&&!rl&&r
193575
$day and $mon
!ll&&!rl&&r
163578
MC/DC100%3/3
$day and $mon and $year
$day $mon $year
Truth table100%4/4
A and B and C
A= $dayB= $monC= $year
ABCresult
0XX0
10X0
1100
1111
133 575 ▶ if($dt) { # DateTime.pm loaded
Branch: 2 branches
BranchTrueFalseTotal
if ($dt) { } 220 355 575
elsif ($di) { } 171 184 355
134 220 $this = DateTime->new(day=>$day,month=>$mon,year=>$year);
135 } elsif($di) { # Date::ICal loaded
136 171 $this = Date::ICal->new(day=>$day,month=>$mon,year=>$year,offset=>0);
137 } else { # using Time::Local
138 184 ▶ return if(fail_range($year));
Branch: 1 branch
BranchTrueFalseTotal
if fail_range($year) 2 182 184
139 182 $this = timegm(0,0,12,$day,$mon-1,$year);
140 }
141 }
142  
143 595 return $this
144 }
145  
146 =item decode_date( date )
147  
148 Translates the given date object into date values.
149  
150 =cut
151  
152 # name: decode_date
153 # args: date1 .... date object or number
154 # retv: the standard numerical day/month/year values
155 # desc: Translates the date object or number into date values.
156  
157 sub decode_date {
158 2838 ▶ my $date = shift || return;
Subroutine decode_date: called CC=4 SCAR=13.9
Pod documented
Condition100%2/2
shift() || (return)
l!l
28335
MC/DC100%1/1
shift() || (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
159 2833 my ($day,$month,$year,$dow);
160  
161 2833 ▶ if($dt) { # DateTime.pm loaded
Branch: 2 branches
BranchTrueFalseTotal
if ($dt) { } 934 1899 2833
elsif ($di) { } 921 978 1899
162 934 ($day,$month,$year,$dow) =
163 ($date->day,$date->month,$date->year,$date->dow);
164 934 $dow %= 7;
165 } elsif($di) { # Date::ICal loaded
166 921 ($day,$month,$year,$dow) =
167 ($date->day,$date->month,$date->year,$date->day_of_week);
168 } else { # using Time::Local
169 978 ($day,$month,$year,$dow) = (localtime($date))[3..6];
170 978 (undef,undef,undef,$day,$month,$year,$dow) = (localtime($date));
171 978 $month++;
172 978 $year+=1900;
173 }
174  
175 2833 return $day,$month,$year,$dow;
176 }
177  
178 =item compare_dates( date, date )
179  
180 Using the appropriate method, determines the ordering of the two given dates.
181  
182 =cut
183  
184 # name: compare_dates
185 # args: date1 .... date object or string
186 # date2 .... date object or string
187 # retv: the compare value, as per the 'cmp' or '<=>' functionality.
188 # desc: Using the selected module, determines whether the first date is before,
189 # after or the same as the second.
190  
191 sub compare_dates {
192 1708 ▶ my ($d1,$d2) = @_;
Subroutine compare_dates: called CC=10 SCAR=23.0
Pod documented
193 1708 ▶ return 0 if(! defined $d1 && ! defined $d2);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d1 or defined $d2 6 1702 1708
Condition100%3/3
defined $d1 or defined $d2
l!l&&r!l&&!r
169666
MC/DC100%2/2
defined $d1 or defined $d2
defined $d1 defined $d2
Truth table100%3/3
A or B
A= defined $d1B= defined $d2
ABresult
1X1
011
000
194 1702 ▶ return 1 if( defined $d1 && ! defined $d2);
Branch: 1 branch
BranchTrueFalseTotal
if defined $d1 and not defined $d2 714 988 1702
Condition100%3/3
defined $d1 and not defined $d2
!ll&&!rl&&r
6982714
MC/DC100%2/2
defined $d1 and not defined $d2
defined $d1 not defined $d2
Truth table100%3/3
A and not(B)
A= defined $d1B= not defined $d2
ABresult
0X0
100
111
195 988 ▶ return -1 if(! defined $d1);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $d1 6 982 988
196  
197 982 my $diff = 0;
198 982 ▶ if($dt) { $diff = DateTime->compare( $d1, $d2 ); }
Branch: 2 branches
BranchTrueFalseTotal
if ($dt) { } 320 662 982
elsif ($di) { } 312 350 662
199 312 elsif($di) { $diff = $d1->compare($d2); }
200 350 ▶ else { $diff = $d1 < $d2 ? -1 : ($d1 > $d2 ? 1 : 0); }
Branch: 2 branches
BranchTrueFalseTotal
$d1 < $d2 ? : 304 46 350
$d1 > $d2 ? : 20 26 46
201  
202 982 return $diff;
203 }
204  
205 =item add_day( date )
206  
207 Add one day to the date object.
208  
209 =cut
210  
211 sub add_day {
212 1548 ▶ my $d1 = shift;
Subroutine add_day: called CC=3 SCAR=11.0
Pod documented
213  
214 1548 ▶ if($dt) { $d1->add( days => 1 ); }
Branch: 2 branches
BranchTrueFalseTotal
if ($dt) { } 506 1042 1548
elsif ($di) { } 506 536 1042
215 506 elsif($di) { $d1->add( day => 1 ); }
216 536 else { $d1 += 60 * 60 * 24; }
217  
218 1548 return $d1;
219 }
220  
221 =item format_date( fmt, day, mon, year [, dotw])
222  
223 transposes the standard date values into a formatted string.
224  
225 =cut
226  
227 # name: format_date
228 # args: fmt ............. format string
229 # day/mon/year .... standard date values
230 # dotw ............ day of the week number (optional)
231 # retv: newly formatted date
232 # desc: Transposes the format string and date values into a correctly
233 # formatted date string.
234  
235 sub format_date {
236 1702 ▶ my ($fmt,$day,$mon,$year,$dotw) = @_;
Subroutine format_date: called CC=10 SCAR=23.0
Pod documented
237 1702 ▶ return unless($day && $mon && $year);
Branch: 1 branch
BranchTrueFalseTotal
unless $day and $mon and $year 2 1699 1701
Condition100%6/6
$day and $mon and $year
!ll&&!rl&&r
211699
$day and $mon
!ll&&!rl&&r
111700
MC/DC100%3/3
$day and $mon and $year
$day $mon $year
Truth table100%4/4
A and B and C
A= $dayB= $monC= $year
ABCresult
0XX0
10X0
1100
1111
238  
239 1699 ▶ unless($dotw) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dotw) 228 1471 1699
240 228 (undef,undef,undef,$dotw) = decode_date(encode_date($day,$mon,$year));
241 }
242  
243 # create date mini strings
244 1699 my $fday = sprintf "%02d", $day;
245 1699 my $fmon = sprintf "%02d", $mon;
246 1699 my $fyear = sprintf "%04d", $year;
247 1699 my $fmonth = sprintf "%s", $months[$mon];
248 1699 my $fdotw = sprintf "%s", $dotw[$dotw];
249 1699 my $fddext = sprintf "%d%s", $day, ext($day);
250 1699 my $amonth = substr($fmonth,0,3);
251 1699 my $adotw = substr($fdotw,0,3);
252 1699 my $epoch = -1; # an arbitory number
253  
254 # epoch only supports the same dates in the 32-bit range
255 1699 ▶ if($tp && $fmt =~ /\bEPOCH\b/ && $year >= $EpoYear && $year <= $MaxYear) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tp and $fmt =~ /\bEPOCH\b/ and $year >= $EpoYear and $year <= $MaxYear) 3 1696 1699
Condition88%8/9
$tp and $fmt =~ /\bEPOCH\b/ and $year >= $EpoYear and $year <= $MaxYear
!ll&&!rl&&r
169423
$tp and $fmt =~ /\bEPOCH\b/ and $year >= $EpoYear
!ll&&!rl&&r
169225
$tp and $fmt =~ /\bEPOCH\b/
!ll&&!rl&&r
016927
MC/DC75%3/4
$tp and $fmt =~ /\bEPOCH\b/ and $year >= $EpoYear and $year <= $MaxYear
$tp $fmt =~ /\bEPOCH\b/ $year >= $EpoYear $year <= $MaxYear
Truth table80%4/5
A and B and C and D
A= $tpB= $fmt =~ /\bEPOCH\b/C= $year >= $EpoYearD= $year <= $MaxYear
ABCDresult
0XXX0
10XX0
110X0
11100
11111
256 3 my $date = timegm 0, 0, 12, $day, $mon -1, $year;
257 3 my $t = Time::Piece::gmtime($date);
258 3 ▶ $epoch = $t->epoch if($t);
Branch: 1 branch
BranchTrueFalseTotal
if $t 3 0 3
259 }
260  
261 # transpose format string into a date string
262 1699 $fmt =~ s/\bDMY\b/$fday-$fmon-$fyear/i;
263 1699 $fmt =~ s/\bMDY\b/$fmon-$fday-$fyear/i;
264 1699 $fmt =~ s/\bYMD\b/$fyear-$fmon-$fday/i;
265 1699 $fmt =~ s/\bMABV\b/$amonth/i;
266 1699 $fmt =~ s/\bDABV\b/$adotw/i;
267 1699 $fmt =~ s/\bMONTH\b/$fmonth/i;
268 1699 $fmt =~ s/\bDAY\b/$fdotw/i;
269 1699 $fmt =~ s/\bDDEXT\b/$fddext/i;
270 1699 $fmt =~ s/\bYYYY\b/$fyear/i;
271 1699 $fmt =~ s/\bMM\b/$fmon/i;
272 1699 $fmt =~ s/\bDD\b/$fday/i;
273 1699 $fmt =~ s/\bEPOCH\b/$epoch/i;
274  
275 1699 return $fmt;
276 }
277  
278 =item reformat_date( date, form1, form1 )
279  
280 transposes the standard date values into a formatted string.
281  
282 =cut
283  
284 # name: reformat_date
285 # args: date ..... date string
286 # form1 .... format string
287 # form2 .... format string
288 # retv: converted date string
289 # desc: Transposes the date from one format to another.
290  
291 sub reformat_date {
292 8 ▶ my ($date,$form1,$form2) = @_;
Subroutine reformat_date: called CC=13 SCAR=25.6
Pod documented
293 8 my ($year,$mon,$day,$dotw) = ();
294  
295 8 ▶ while($form1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($form1) 49 8 57
296 49 ▶ if($form1 =~ /^YYYY/) {
Branch: 6 branches
BranchTrueFalseTotal
if ($form1 =~ /^YYYY/) { } 8 41 49
elsif ($form1 =~ /^MONTH/) { } 3 38 41
elsif ($form1 =~ /^MM/) { } 5 33 38
elsif ($form1 =~ /^DDEXT/) { } 3 30 33
elsif ($form1 =~ /^DD/) { } 5 25 30
elsif ($form1 =~ /^DAY/) { } 3 22 25
297 8 ($year) = ($date =~ /^(\d{4})/);
298 8 $form1 =~ s/^....//;
299 8 $date =~ s/^....//;
300  
301 } elsif($form1 =~ /^MONTH/) {
302 3 my ($month) = ($date =~ /^(\w+)/);
303 3 $mon = moty($month);
304 3 $form1 =~ s/^\w+//;
305 3 $date =~ s/^\w+//;
306  
307 } elsif($form1 =~ /^MM/) {
308 5 ($mon) = ($date =~ /^(\d{2})/);
309 5 $form1 =~ s/^..//;
310 5 $date =~ s/^..//;
311  
312 } elsif($form1 =~ /^DDEXT/) {
313 3 ($day) = ($date =~ /^(\d{1,2})/);
314 3 $form1 =~ s/^.....//;
315 3 $date =~ s/^\d{1,2}..//;
316  
317 } elsif($form1 =~ /^DD/) {
318 5 ($day) = ($date =~ /^(\d{2})/);
319 5 $form1 =~ s/^..//;
320 5 $date =~ s/^..//;
321  
322 } elsif($form1 =~ /^DAY/) {
323 3 my ($wday) = ($date =~ /^(\w+)/);
324 3 $dotw = dotw($wday);
325 3 $form1 =~ s/^\w+//;
326 3 $date =~ s/^\w+//;
327  
328 } else {
329 22 $form1 =~ s/^.//;
330 22 $date =~ s/^.//;
331 }
332 }
333  
334 # return original date if badly formed date
335 8 ▶ return $_[0] unless(int($day) && int($mon) && int($year));
Branch: 1 branch
BranchTrueFalseTotal
unless int $day and int $mon and int $year 2 5 7
Condition100%6/6
int $day and int $mon and int $year
!ll&&!rl&&r
215
int $day and int $mon
!ll&&!rl&&r
116
MC/DC100%3/3
int $day and int $mon and int $year
int $day int $mon int $year
Truth table100%4/4
A and B and C
A= int $dayB= int $monC= int $year
ABCresult
0XX0
10X0
1100
1111
336  
337 # get the day of the week, if we need it
338 5 ▶ $dotw = dotw($day,$mon,$year) if($form2 =~ /DAY/ && !$dotw);
Branch: 1 branch
BranchTrueFalseTotal
if $form2 =~ /DAY/ and not $dotw 1 4 5
Condition100%3/3
$form2 =~ /DAY/ and not $dotw
!ll&&!rl&&r
311
MC/DC100%2/2
$form2 =~ /DAY/ and not $dotw
$form2 =~ /DAY/ not $dotw
Truth table100%3/3
A and not(B)
A= $form2 =~ /DAY/B= not $dotw
ABresult
0X0
100
111
339  
340 # rebuild date into second format
341 5 return format_date($form2,$day,$mon,$year,$dotw);
342 }
343  
344 =item ext( day )
345  
346 Returns the extension associated with the given day value.
347  
348 =cut
349  
350 # name: ext
351 # args: day .... day value
352 # retv: day value extension
353 # desc: Returns the extension associated with the given day value.
354  
355 sub ext {
356 1730 ▶ return 'st' if($_[0] == 1 ||$_[0] == 21 || $_[0] == 31);
Subroutine ext: called CC=8 SCAR=20.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] == 1 or $_[0] == 21 or $_[0] == 31 74 1555 1629
Condition100%6/6
$_[0] == 1 or $_[0] == 21 or $_[0] == 31
l!l&&r!l&&!r
132431555
$_[0] == 1 or $_[0] == 21
l!l&&r!l&&!r
101311598
MC/DC100%3/3
$_[0] == 1 or $_[0] == 21 or $_[0] == 31
$_[0] == 1 $_[0] == 21 $_[0] == 31
Truth table100%4/4
A or B or C
A= $_[0] == 1B= $_[0] == 21C= $_[0] == 31
ABCresult
1XX1
01X1
0011
0000
357 1555 ▶ return 'nd' if($_[0] == 2 ||$_[0] == 22);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] == 2 or $_[0] == 22 115 1440 1555
Condition100%3/3
$_[0] == 2 or $_[0] == 22
l!l&&r!l&&!r
84311440
MC/DC100%2/2
$_[0] == 2 or $_[0] == 22
$_[0] == 2 $_[0] == 22
Truth table100%3/3
A or B
A= $_[0] == 2B= $_[0] == 22
ABresult
1X1
011
000
358 1440 ▶ return 'rd' if($_[0] == 3 ||$_[0] == 23);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] == 3 or $_[0] == 23 143 1297 1440
Condition100%3/3
$_[0] == 3 or $_[0] == 23
l!l&&r!l&&!r
112311297
MC/DC100%2/2
$_[0] == 3 or $_[0] == 23
$_[0] == 3 $_[0] == 23
Truth table100%3/3
A or B
A= $_[0] == 3B= $_[0] == 23
ABresult
1X1
011
000
359 1297 return 'th';
360 }
361  
362 =item dotw( day | dayname )
363  
364 Returns the day number (0..6) if passed the day name, or the day
365 name if passed a numeric.
366  
367 =cut
368  
369 sub dotw {
370 20 ▶ return $dotw[$_[0]] if($_[0] =~ /\d/);
Subroutine dotw: called CC=4 SCAR=13.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /\d/ 9 11 20
371  
372 11 foreach my $inx (0..6) {
373 44 ▶ return $inx if($_[0] =~ /$dotw[$inx]/i);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /$dotw[$inx]/i 10 34 44
374 }
375  
376 1 return;
377 }
378  
379 =item moty( month | monthname )
380  
381 Returns the month number (1..12) if passed the month name, or the month
382 name if passed a numeric.
383  
384 =cut
385  
386 sub moty {
387 29 ▶ return $months[$_[0]] if($_[0] =~ /\d/);
Subroutine moty: called CC=4 SCAR=13.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /\d/ 13 16 29
388  
389 16 foreach my $inx (1..12) {
390 112 ▶ return $inx if($_[0] =~ /$months[$inx]/i);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /$months[$inx]/i 15 97 112
391 }
392  
393 1 return;
394 }
395  
396 =item fail_range( year )
397  
398 Returns true or false based on whether the date given will break the
399 basic date range, 01-01-1902 to 31-12-2037.
400  
401 =cut
402  
403 sub fail_range {
404 202 ▶ return 1 unless($_[0]);
Subroutine fail_range: called CC=6 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 3 199 202
405 199 ▶ return 0 if($dt || $di);
Branch: 1 branch
BranchTrueFalseTotal
if $dt or $di 10 189 199
Condition100%3/3
$dt or $di
l!l&&r!l&&!r
55189
MC/DC100%2/2
$dt or $di
$dt $di
Truth table100%3/3
A or B
A= $dtB= $di
ABresult
1X1
011
000
406 189 ▶ return 1 if($_[0] < $MinYear || $_[0] > $MaxYear);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] < $MinYear or $_[0] > $MaxYear 4 185 189
Condition100%3/3
$_[0] < $MinYear or $_[0] > $MaxYear
l!l&&r!l&&!r
22185
MC/DC100%2/2
$_[0] < $MinYear or $_[0] > $MaxYear
$_[0] < $MinYear $_[0] > $MaxYear
Truth table100%3/3
A or B
A= $_[0] < $MinYearB= $_[0] > $MaxYear
ABresult
1X1
011
000
407 185 return 0;
408 }
409  
410 sub _caltest {
411 7 ▶ $dt = $_[0] if($dt);
Subroutine _caltest: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
if $dt 7 0 7
412 7 ▶ $di = $_[1] if($di);
Branch: 1 branch
BranchTrueFalseTotal
if $di 7 0 7
413 }
414  
415 18 1;
416  
417 __END__
418  
419 #----------------------------------------------------------------------------
420  
421 =back
422  
423 =head1 DATE FORMATS
424  
425 =over 4
426  
427 =item Parameters
428  
429 The date formatting parameters passed to the two formatting functions can
430 take many different formats. A formatting string can contain several key
431 strings, which will be replaced with date components. The following are
432 key strings which are currently supported:
433  
434 DD
435 MM
436 YYYY
437 DAY
438 MONTH
439 DDEXT
440 DMY
441 MDY
442 YMD
443 MABV
444 DABV
445  
446 The first three are tranlated into the numerical day/month/year strings.
447 The DAY format is translated into the day of the week name, and MONTH
448 is the month name. DDEXT is the day with the appropriate suffix, eg 1st,
449 22nd or 13th. DMY, MDY and YMD default to '13-09-1965' (DMY) style strings.
450 MABV and DABV provide 3 letter abbreviations of MONTH and DAY respectively.
451  
452 =back
453  
454 =head1 DATE MODULES
455  
456 Internal to this module is some date comparison code. As a consequence this
457 requires some date modules that can handle a wide range of dates. There are
458 three modules which are tested for you, these are, in order of preference,
459 DateTime, Date::ICal and Time::Local.
460  
461 Each module has the ability to handle dates, although only Time::Local exists
462 in the core release of Perl. Unfortunately Time::Local is limited by the
463 Operating System. On a 32bit machine this limit means dates before 1st January
464 1902 and after 31st December 2037 will not be represented. If this date range
465 is well within your scope, then you can safely allow the module to use
466 Time::Local. However, should you require a date range that exceedes this
467 range, then it is recommended that you install one of the two other modules.
468  
469 =head1 ERROR HANDLING
470  
471 In the event that Time::Local is being used and dates that exceed the range
472 of 1st January 1902 to 31st December 2037 are passed, an undef is returned.
473  
474 =head1 SEE ALSO
475  
476 L<Date::ICal>
477 L<DateTime>
478 L<Time::Local>
479 L<Time::Piece>
480  
481 The Calendar FAQ at http://www.tondering.dk/claus/calendar.html
482  
483 =head1 BUGS, PATCHES & FIXES
484  
485 There are no known bugs at the time of this release. However, if you spot a
486 bug or are experiencing difficulties that are not explained within the POD
487 documentation, please submit a bug to the RT system (see link below). However,
488 it would help greatly if you are able to pinpoint problems or even supply a
489 patch.
490  
491 Fixes are dependent upon their severity and my availability. Should a fix not
492 be forthcoming, please feel free to (politely) remind me by sending an email
493 to barbie@cpan.org .
494  
495 RT: http://rt.cpan.org/Public/Dist/Display.html?Name=Calendar-List
496  
497 =head1 AUTHOR
498  
499 Barbie, <barbie@cpan.org>
500 for Miss Barbell Productions <http://www.missbarbell.co.uk>.
501  
502 =head1 THANKS TO
503  
504 Dave Cross, E<lt>dave at dave.orgE<gt> for creating Calendar::Simple, the
505 newbie poster on a technical message board who inspired me to write the
506 original wrapper code and Richard Clamp E<lt>richardc at unixbeard.co.ukE<gt>
507 for testing the beta versions.
508  
509 =head1 COPYRIGHT AND LICENSE
510  
511 Copyright (C) 2003-2019 Barbie for Miss Barbell Productions
512  
513 This distribution is free software; you can redistribute it and/or
514 modify it under the Artistic License v2.
515  
516 =cut
↑ Summary List.pm »