1Calendar::Simple(3)   User Contributed Perl Documentation  Calendar::Simple(3)
2
3
4

NAME

6       Calendar::Simple - Perl extension to create simple calendars
7

SYNOPSIS

9         use Calendar::Simple;
10
11         my @curr      = calendar;             # get current month
12         my @this_sept = calendar(9);          # get 9th month of current year
13         my @sept_2002 = calendar(9, 2002);    # get 9th month of 2002
14         my @monday    = calendar(9, 2002, 1); # get 9th month of 2002,
15                                               # weeks start on Monday
16
17         my @span      = date_span(mon   => 10,  # returns span of dates
18                                   year  => 2006,
19                                   begin => 15,
20                                   end   => 28);
21

DESCRIPTION

23       A very simple module that exports one function called "calendar".
24
25   calendar
26       This function returns a data structure representing the dates in a
27       month.  The data structure returned is an array of array references.
28       The first level array represents the weeks in the month. The second
29       level array contains the actual days. By default, each week starts on a
30       Sunday and the value in the array is the date of that day. Any days at
31       the beginning of the first week or the end of the last week that are
32       from the previous or next month have the value "undef".
33
34       If the month or year parameters are omitted then the current month or
35       year are assumed.
36
37       A third, optional parameter, start_day, allows you to set the day each
38       week starts with, with the same values as localtime sets for wday
39       (namely, 0 for Sunday, 1 for Monday and so on).
40
41   date_span
42       This function returns a cur-down version of a month data structure
43       which begins and ends on dates other than the first and last dates of
44       the month.  Any weeks that fall completely outside of the date range
45       are removed from the structure and any days within the remaining weeks
46       that fall outside of the date range are set to "undef".
47
48       As there are a number of parameters to this function, they are passed
49       using a named parameter interface. The parameters are as follows:
50
51       year
52           The required year. Defaults to the current year if omitted.
53
54       mon The required month. Defaults to the current month if omitted.
55
56       begin
57           The first day of the required span. Defaults to the first if
58           omitted.
59
60       end The last day of the required span. Defaults to the last day of the
61           month if omitted.
62
63       start_day
64           Indicates the day of the week that each week starts with. This
65           takes the same values as the optional third parameter to
66           "calendar". The default is 0 (for Sunday).
67
68       This function isn't exported by default, so in order to use it in your
69       program you need to use the module like this:
70
71         use Calendar::Simple 'date_span';
72
73   EXAMPLE
74       A simple "cal" replacement would therefore look like this:
75
76         #!/usr/bin/perl -w
77
78         use strict;
79         use Calendar::Simple;
80
81         my @months = qw(January February March April May June July August
82                         September October November December);
83
84         my $mon = shift || (localtime)[4] + 1;
85         my $yr  = shift || (localtime)[5] + 1900;
86
87         my @month = calendar($mon, $yr);
88
89         print "\n$months[$mon -1] $yr\n\n";
90         print "Su Mo Tu We Th Fr Sa\n";
91         foreach (@month) {
92           print map { $_ ? sprintf "%2d ", $_ : '   ' } @$_;
93           print "\n";
94         }
95
96       A version of this example, called "pcal", is installed when you install
97       this module.
98
99   Date Range
100       This module will make use of DateTime.pm if it is installed. By using
101       DateTime.pm it can use any date that DateTime can represent. If
102       DateTime is not installed it uses Perl's built-in date handling and
103       therefore can't deal with dates before 1970 and it will also have
104       problems with dates after 2038 on a 32-bit machine.
105
106   EXPORT
107       "calendar"
108

AUTHOR

110       Dave Cross <dave@mag-sol.com>
111

ACKNOWLEDGEMENTS

113       With thanks to Paul Mison <cpan@husk.org> for the start day patch.
114
116       Copyright (C) 2002-2008, Magnum Solutions Ltd.  All Rights Reserved.
117

LICENSE

119       This script is free software; you can redistribute it and/or modify it
120       under the same terms as Perl itself.
121

SEE ALSO

123       perl, localtime, DateTime
124
125
126
127perl v5.28.0                      2018-02-22               Calendar::Simple(3)
Impressum