Use with an argument of "yyyy-mm", or with no argument to get the current month. I made this because it was easier than hacking the existing cal tool to do what I want. This snippet is very configurable, but only by hacking its source :)
#!/usr/bin/perl -w use strict; use Calendar::Simple qw(calendar); use POSIX qw(strftime); my $today = strftime '%Y-%m-%d', localtime; my ($year, $month) = split /-/, shift || $today; printf "\n%04d-%02d\n\n", $year, $month; print "\e[1mMon Tue Wed Thu Fri Sat Sun\e[0m\n"; for (calendar $month, $year, 1) { for (@$_) { no warnings; $_ = sprintf '%3s', $_ || ''; $_ = "\e[7m$_\e[0m" if sprintf("%04d-%02d-%02d", $year, $month, $_) eq $today; } print "@$_\n"; } print "\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Very simple calendar
by merlyn (Sage) on Dec 21, 2003 at 23:12 UTC | |
by Juerd (Abbot) on Dec 21, 2003 at 23:26 UTC | |
Re: Very simple calendar
by theguvnor (Chaplain) on Dec 21, 2003 at 21:07 UTC | |
by The Mad Hatter (Priest) on Dec 21, 2003 at 21:32 UTC | |
by Juerd (Abbot) on Dec 21, 2003 at 23:13 UTC | |
by Juerd (Abbot) on Dec 21, 2003 at 23:11 UTC | |
by theguvnor (Chaplain) on Dec 22, 2003 at 03:09 UTC |
Back to
Cool Uses for Perl