HTML-Make-Calendar
view release on metacpan or search on metacpan
examples/menu.pl view on Meta::CPAN
use utf8;
use FindBin '$Bin';
use HTML::Make::Calendar 'calendar';
binmode STDOUT, ":encoding(utf8)";
my @foods = split '', <<EOF;
ðððððððð¥ððððððð¥ð
ð¥
ð
ð¥ð¥¬ð¥¦ð§ð§
ðð¥ð°ððððððð ð¢
ð£ð¤ð¥ð¥®ð¡ð¥ð¥ ð¥¡ð¦ªð¦ð§ð¨ð©ðªðð°ð§
EOF
@foods = grep {!/\s/} @foods;
my $cal = calendar (cdata => \@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) {
examples/moon.pl view on Meta::CPAN
#!/home/ben/software/install/bin/perl
use warnings;
use strict;
use utf8;
use HTML::Make::Calendar 'calendar';
use Astro::MoonPhase;
use Date::Calc 'Date_to_Time';
binmode STDOUT, ":encoding(utf8)";
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)] . " <b>$date->{dom}</b>";
lib/HTML/Make/Calendar.pm view on Meta::CPAN
sub add_month_heading
{
my ($o, $tbody) = @_;
# Add the title to the calendar
my $titler = $tbody->push ('tr');
my $titleh = $titler->push ('th', attr => {colspan => 7});
my $my;
if ($o->{monthc}) {
my $date = {month => $o->{month}, year => $o->{year}};
$my = &{$o->{monthc}} ($o->{cdata}, $date, $titleh);
}
else {
$my = Month_to_Text ($o->{month}) . " $o->{year}";
$titleh->add_text ($my);
}
# To do: Allow the caller to override this.
my $wdr = $tbody;
if (! $o->{weekless}) {
$wdr = $tbody->push ('tr');
}
lib/HTML/Make/Calendar.pm view on Meta::CPAN
{
my (%options) = @_;
my $o = {};
bless $o;
$o->option (\%options, 'verbose');
($o->{year}, $o->{month}, undef) = Today ();
$o->option (\%options, 'year');
$o->option (\%options, 'month');
$o->option (\%options, 'dayc');
$o->option (\%options, 'monthc');
$o->option (\%options, 'cdata');
$o->{first} = 1;
$o->option (\%options, 'first');
$o->check_first ();
$o->option (\%options, 'weekless');
$o->option (\%options, 'daynames');
# To do: Allow the user to use their own HTML tags.
$o->{month_html} = $html{month}{element};
$o->{week_html} = $html{week}{element};
$o->{day_html} = $html{day}{element};
$o->option (\%options, 'month_html');
lib/HTML/Make/Calendar.pm view on Meta::CPAN
for my $col (1..7) {
# dow = day of week
my $dow = $o->{col2dow}{$col};
my $day = add_el ($week, $html{day}, $o->{day_html});
my $cell = shift @cells;
# dom = day of month
my $dom = $cell->{dom};
if (defined $dom) {
$day->add_class ('cal-' . $dowclass[$dow]);
if ($o->{dayc}) {
&{$o->{dayc}} ($o->{cdata},
{
year => $o->{year},
month => $o->{month},
dom => $dom,
dow => $dow,
wom => $wom,
},
$day);
}
else {
lib/HTML/Make/Calendar.pod view on Meta::CPAN
=end html
(This example is included as L<F<calendar.pl>|https://fastapi.metacpan.org/source/BKB/HTML-Make-Calendar-0.01/examples/calendar.pl> in the distribution.)
The possible arguments are
=over
=item cdata
Callback data, see L</dayc>.
=item day_html
Override the HTML element used to make the "day" cells. The default is
C<td>. If you override this then you also need to override the parent
elements, otherwise HTML::Make will fuss about compatibility.
=item dayc
Day callback which fills in the "day" cell of the calendar. If this is
omitted, a default element is added. The day callback is called with
three arguments, first L</cdata>, your data, second the date as a hash
reference with arguments C<year>, C<month> and C<dom> (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, like this:
&{$dayc} ($cdata, {year => 2020, month => 12, dom => 21}, $td);
where C<$td> is an L<HTML::Make> object.
=item daynames
Specify the names of the days. See L</Japanese calendar> for an
example.
=item first
lib/HTML/Make/Calendar.pod view on Meta::CPAN
=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<Date::Calc/Today>.
=back
=head3 Phases of the moon
This example demonstrates the use of L</dayc> and L</cdata> by adding
the phase of the moon to your calendar. It requires
L<Astro::MoonPhase> (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)] . " <b>$date->{dom}</b>";
lib/HTML/Make/Calendar.pod view on Meta::CPAN
</table>
=end html
(This example is included as L<F<moon.pl>|https://fastapi.metacpan.org/source/BKB/HTML-Make-Calendar-0.01/examples/moon.pl> in the distribution.)
=head3 Daily menu
This example demonstrates the use of L</dayc> and L</cdata>, 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 '', <<EOF;
ðððððððð¥ððððððð¥ð
ð¥
ð
ð¥ð¥¬ð¥¦ð§ð§
ðð¥ð°ððððððð ð¢
ð£ð¤ð¥ð¥®ð¡ð¥ð¥ ð¥¡ð¦ªð¦ð§ð¨ð©ðªðð°ð§
EOF
@foods = grep {!/\s/} @foods;
my $cal = calendar (cdata => \@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) {
( run in 0.614 second using v1.01-cache-2.11-cpan-454fe037f31 )