=encoding UTF-8 =head1 NAME HTML::Make::Calendar - Make an HTML calendar =head1 SYNOPSIS use HTML::Make::Calendar; =head1 VERSION This documents version 0.00_04 of HTML-Make-Calendar corresponding to L released on Mon Jan 11 21:49:35 2021 +0900. =head1 DESCRIPTION This module constructs HTML calendars. =head1 FUNCTIONS =head2 calendar my $out = calendar (year => 2010, month => 10); Make the calendar. The return value is an HTML::Make object. To get the actual HTML, call its C
     method:

        use utf8;
        use FindBin '$Bin';
        use HTML::Make::Calendar 'calendar';
        my $out = calendar (year => 2021, month => 1);
        print $out->text ();

    =begin html

The output HTML looks like this:

January 2021
Mo | Tu | We | Th | Fr | Sa | Su
--- | --- | --- | --- | --- | --- | ---
|  |  |  | 1 | 2 | 3
4 | 5 | 6 | 7 | 8 | 9 | 10
11 | 12 | 13 | 14 | 15 | 16 | 17
18 | 19 | 20 | 21 | 22 | 23 | 24
25 | 26 | 27 | 28 | 29 | 30 | 31

=end html (This example is included as L|https://fastapi.metacpan.org/source/BKB/HTML-Make-Calendar-0.00_04/examples/calendar.pl> in the distribution.) The possible arguments are =over =item cdata Callback data, see L. =item dayc Day callback. If this is omitted, a default element is added. The day callback is called with three arguments, first L, second the date as a hash reference with arguments C, C and C (day of month, a number from 1 to 31), and third the HTML element to attach the return value to, representing the cell of the calendar. &{$dayc} ($cdata, {year => 2020, month => 12, day => 21}, $td); where C<$td> is an L object. =item first The first day of the week. The default is 1 for Monday. Specify 7 to start on Sunday: use HTML::Make::Calendar 'calendar'; my $cal = calendar (first => 7); print $cal->text (); =begin html

The output HTML looks like this:

January 2021
Su | Mo | Tu | We | Th | Fr | Sa
--- | --- | --- | --- | --- | --- | ---
|  |  |  |  | 1 | 2
3 | 4 | 5 | 6 | 7 | 8 | 9
10 | 11 | 12 | 13 | 14 | 15 | 16
17 | 18 | 19 | 20 | 21 | 22 | 23
24 | 25 | 26 | 27 | 28 | 29 | 30
31 |  |  |  |  |  |

=end html (This example is included as L|https://fastapi.metacpan.org/source/BKB/HTML-Make-Calendar-0.00_04/examples/first.pl> in the distribution.) Any other day of the week may also be used, for example specify 3 to start the weeks on Wednesdays. =item month The month, as a number from 1 to 12. If the month is omitted, the current month is used as given by L. =item year The year, as a four-digit number like C<2020>. If the year is omitted, the current year is used, as given by L. =back =head3 Phases of the moon This example demonstrates the use of L and L by adding the phase of the moon to your calendar. It requires L
     (not included with this distribution).

        use utf8;
        use HTML::Make::Calendar 'calendar';
        use Astro::MoonPhase;
        use Date::Calc 'Date_to_Time';
        my @moons = qw!🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘!;
        my $cal = calendar (dayc => \&daymoon, cdata => \@moons);
        print $cal->text ();
        exit;

        sub daymoon
        {
            my ($moons, $date, $element) = @_;
            my $epochtime = Date_to_Time ($date->{year}, $date->{month},
                                          $date->{dom}, 0, 0, 0);
            my ($phase) = phase ($epochtime);
            my $text = $moons->[int (8*$phase)] . "
$date->{dom}
    ";
            $element->add_text ($text);
        }

    =begin html

The output HTML looks like this:

January 2021
Mo | Tu | We | Th | Fr | Sa | Su
--- | --- | --- | --- | --- | --- | ---
|  |  |  | 🌕 1 | 🌕 2 | 🌖 3
🌖 4 | 🌖 5 | 🌖 6 | 🌗 7 | 🌗 8 | 🌗 9 | 🌘 10
🌘 11 | 🌘 12 | 🌘 13 | 🌑 14 | 🌑 15 | 🌑 16 | 🌒 17
🌒 18 | 🌒 19 | 🌒 20 | 🌓 21 | 🌓 22 | 🌓 23 | 🌓 24
🌓 25 | 🌔 26 | 🌔 27 | 🌔 28 | 🌕 29 | 🌕 30 | 🌕 31

=end html (This example is included as L|https://fastapi.metacpan.org/source/BKB/HTML-Make-Calendar-0.00_04/examples/moon.pl> in the distribution.) =head3 Daily menu This example demonstrates the use of L and L, and how to add your own HTML into the cells of the calendar. use utf8; use FindBin '$Bin'; use HTML::Make::Calendar 'calendar'; my @foods = split '', <
     \@foods, dayc => \&add_food);
        print $cal->text ();
        exit;

        sub add_food
        {
            my ($foods, $date, $element) = @_;
            my $today =
            $element->push ('span', text => $date->{dom});
            my $menu = HTML::Make->new ('ol');
            for (1..3) {
                my $food = $foods->[int (rand (@$foods))];
                $menu->push ('li', text => $food);
            }
            $element->push ($menu);
        }

    =begin html

The output HTML looks like this:

January 2021
Mo | Tu | We | Th | Fr | Sa | Su
--- | --- | --- | --- | --- | --- | ---
|  |  |  | 1 🍰 🍄 🥒 | 2 🍥 🍦 🍅 | 3 🧁 🍛 🥮
4 🍇 🍠 🍝 | 5 🍄 🧅 🍎 | 6 🍉 🍒 🍄 | 7 🍈 🥦 🍈 | 8 🍇 🍏 🍍 | 9 🧄 🍚 🍦 | 10 🥟 🎂 🍍
11 🍑 🥝 🥮 | 12 🍈 🍉 🍢 | 13 🍅 🍑 🍪 | 14 🍠 🍓 🦪 | 15 🍈 🌰 🍈 | 16 🥬 🥝 🥮 | 17 🍢 🥝 🍧
18 🍜 🧁 🍅 | 19 🍥 🍙 🍪 | 20 🥝 🥡 🍋 | 21 🍍 🍤 🥡 | 22 🍘 🍅 🥦 | 23 🧄 🍤 🍍 | 24 🥒 🍢 🍍
25 🍩 🍇 🍊 | 26 🍣 🍨 🥬 | 27 🍅 🍥 🥟 | 28 🍍 🥮 🍇 | 29 🍉 🥮 🍎 | 30 🍓 🍒 🥝 | 31 🍋 🍠 🍣

=end html (This example is included as L|https://fastapi.metacpan.org/source/BKB/HTML-Make-Calendar-0.00_04/examples/menu.pl> in the distribution.) =head1 DEFAULT HTML ELEMENTS AND CSS CLASSES The elements of the calendar have the following default HTML elements and CSS default style names: =over =item calendar The default HTML element for C (the calendar itself) is C<<

>> with class C. =item week The default HTML element for C (a week) is C<<
>> with class C. =item day The default HTML element for C (a day) is C<< >> with class C as well as class C, C, etc. =item dow The default HTML element for C (the day of the week (Monday, Tuesday, etc.)) is C<< | >> with class C
    .

    =back

    =head1 TERMINOLOGY

    =over

    =item dow = day of the week (Monday, Tuesday, etc.)

    =item dom = day of the month (1 to 31)

    =item wom = week of the month (corresponds to the rows of the calendar)

    =back

    =head1 DEPENDENCIES

    =over

    =item L
Date::Calc supplies the date information for the calendar. =item L HTML::Make is used to generate the HTML for the calendar. =item L Table::Readable is used to read a table of HTML element and CSS class defaults. =back =head1 SCRIPT See L in the distribution. =head1 SEE ALSO =head2 Other CPAN modules =over =item L =item L =item L =item L Includes a script L for making HTML. =item L Fork of L. The documentation is largely copy-pasted from that with some alterations. =item L =item L =item L =item L =back =head2 Other HTML calendar generators =over =item Python The defaults of HTML calendar are somewhat based on Python's L. =back =head1 AUTHOR Ben Bullock, =head1 COPYRIGHT & LICENCE This package and associated files are copyright (C) 2021 Ben Bullock. You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.