File: pcal

package info (click to toggle)
libcalendar-simple-perl 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 116 kB
  • sloc: perl: 106; makefile: 8
file content (31 lines) | stat: -rwxr-xr-x 722 bytes parent folder | download
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
#!/usr/bin/perl

use strict;
use warnings;

use v5.10.0;

use Calendar::Simple;

my @months = qw(January February March April May June July August
                September October November December);

my $month      = shift // (localtime)[4] + 1;
my $year       = shift // (localtime)[5] + 1900;
my $start_date = shift // 1;

$start_date %= 7;

my @month = calendar($month, $year, $start_date);
my $month_name = $months[$month - 1];
my $pad = int((20 - length("$month_name $year")) / 2);
print "\n", ' ' x $pad, "$month_name $year\n";

my @days = qw(Su Mo Tu We Th Fr Sa);
push @days, splice @days, 0, $start_date;
print "@days\n";

foreach (@month) {
  print map { $_ ? sprintf "%2d ", $_ : '   ' } @$_;
  print "\n";
}