Download
here version 1.3
The modules are :
PlotCalendar::Day
PlotCalendar::Month
PlotCalendar::DateTools
PlotCalendar::DateDesc
Day.pm generates a single day, with (for html) controls for colors, fonts, etc.
Month.pm calls Day 28-31 times to create a proper Month-type calendar. Size, day to start week with, colors, etc are all controllable.
DateTools.pm is a pure perl replacement for parts of Date::Calc because I can't compile the c-code in Date::Calc on my webhoster's system.
DateDesc.pm is a simple parser for converting date descriptions like "First Tuesday" into an actual date.
Examples :
Day.pm
my $day = PlotCalendar::Day->new($digit);
$day -> size(100,100);
$day -> color('WHITE','RED',); # foreground and background
$day -> font('14','10','8'); # font size for digits, day-name, and text
$day -> style('bi','nbu','i'); # font styles for same
$day -> cliptext('yes'); # clip long text
$day -> dayname('Groundhog Day');
$day -> nameref('<A href="http://ooga.booga.com/">
$day -> text('text string 1','text string 2','abcdefghijklmno'); # 3 lines of text
$day -> textcolor('BLUE','RED','GREEN',);
$day -> textsize('8','10','8',);
$day -> textstyle('b','u','bi',);
my $html = $day -> gethtml;
Month.pm
my $month = PlotCalendar::Month->new(01,1999);
$month -> size(700,700);
$month -> font('14','10','8');
$month -> cliptext('yes');
$month -> firstday('Sun'); # first column
$month -> fgcolor('BLACK',);
$month -> bgcolor(@bgcolor); # background per day
$month -> styles('b','bi','ui',);
$month -> htmlref(@url); # url for each day
$month -> dayname(@daynames); # names for each day
my $html = $month -> gethtml;
The current (non-beta) version of this module is available from your nearest CPAN site.
The two will frequently be the same.
Time::DaysInMonth
Time::JulianDay
Both these are called by DateTools.pm. I have maintained compatibility
with Date::Calc, so if you wished, you could edit the
use PlotCalendar::DateTools
lines, make them
use Date::Calc
and forget about the Time:: modules and DateTools.
For help with Makefile.PL, try
perldoc ExtUtils::MakeMaker
If you wish to install in a non-standard place, use something like
perl Makefile.PL LIB=~/lib PREFIX=~
To run events_calendar.pl in it's fullest mode, type :
events_calendar.pl -mon 7 -yr 1999 -reg y -spec y > events.html
and view the output in your favorite browser.
If you do report it, please include :
The day is laid out like this :
------------------------------------------ | | | | | digit | digit | Main day name | | | | | | | | | | | | | |---------|--------| | <- bgcolmain | | | | | | | Optional text | | . | | | | Optional Text | | . | | . | | . | | . | | Optional text | | . | | . | | . | | . | ------------------------------------------
Globals : height, width, dayfont, mainfont, optfont, fgcol, bgcolmain, digit
Optionals : dayname, optext[...]
Font sizes in HTML translate as (rounding up) : 6->-1 8->+0 10->+1 12->+2 14->+3Various quantities can be set globally, or over-ridden for specific cases.
This is really meant to be called by month.pm to construct a calendar, but calling it with a *really big size* is a way to ``zoom in'' on a given day
require PlotCalendar::Day;
my $digit=10 ; # do it for the tenth my $day = PlotCalendar::Day->new($digit);
# These are values with default settings, so these are optional
------------ size of whole thing in pixels, X,Y
$day -> size(100,100);
------------ Global foreground and background colors
$day -> color('BLACK','#33cc00',);
$day -> color('WHITE','RED',);
------------ Font sizes for digits, dayname, and optional text
$day -> font('14','10','8');
------------ styles for digits, dayname, and optional text
------------ b=bold, i=italic, u=underline, n=normal
$day -> style('bi','nbu','i');
------------ Clip text to avoid wrapping? (yes/no)
$day -> cliptext('yes');
# HTML only options
------------ is it allowed to expand vertically if there is too much text?
$day -> htmlexpand('yes');
# These values are defaulted to blank
------------ day name
$day -> dayname('Groundhog Day');
------------ if set, name is a hotlink
$day -> nameref('<A href="http://ooga.booga.com/";>');
------------ if set, text string is a hotlink. Note that an array is getting
------------ passed. Text is passed as an array also. Each line of text is
------------ an array element. THis example hotlinks only the first 2 lines.
$day -> textref('<A href="http://booga.booga.com/";>','<A href="mailto:>;');
------------ Text strings, passed as elemnts of an array
$day -> text('text string 1','text string 2','abcdefghijklmno 0 1 2 3 4 5 6 7 8 9 0',);
------------ override default text colors and set each string individually
$day -> textcolor('BLUE','RED','GREEN',);
------------ override default text sizes and set each string individually
$day -> textsize('8','10','8',);
------------ override default text styles and set each string individually
$day -> textstyle('b','u','bi',);
------------ wrap a reference around the entire cell
$day->htmlref('<A href="http://this_is_a_url/";>');
------------ unload what I set my @size = $day->size; my @color = $day->color; my @font = $day->font; my @text = $day->text; my $dayname = $day->dayname;
# So, what do we have now?
------------ Create an ascii text cell #my $text = $day -> gettext;
------------ Create and return html for a cell in a table my $html = $day -> gethtml;
------------ Create and return Tk code (not implemented yet) #my $tk = $day -> gettk;
print "<HTML><BODY>\n"; print "<H1>Normal Day</H1>\n"; print "<TABLE BORDER=1><TR>\n"; print $html; print "</TR></TABLE>\n";
Alan Jackson March 1999 alan@ajackson.org
PlotCalendar::Month - Plot an ASCII or HTML calendar
The month is laid out like this :
Month_name Year
--------------------------------------------------------------- | Sun | Mon | Tue | Wed | Thu | Fri | Sat | --------------------------------------------------------------- | | | | | | | | | day | day | | | | | | | | | | | | | | |--------|--------|--------|-------|--------|--------|--------| | | | | | | | | | day | day | | | | | | | | | | | | | | |--------|--------|--------|-------|--------|--------|--------| | | | | | | | | | day | day | | | | | | | | | | | | | | |--------|--------|--------|-------|--------|--------|--------| | | | | | | | | | day | day | | | | | | | | | | | | | | |--------|--------|--------|-------|--------|--------|--------| | | | | | | | | | day | day | | | | | | | | | | | | | | |--------|--------|--------|-------|--------|--------|--------| | | | | | | | | | day | day | | | | | | optional | | | | | | | | row |--------|--------|--------|-------|--------|--------|--------|
Globals : height, width, fgcol, bgcolmain,
References expect to be given the entire thing, that is <A HREF="http://yaddayaddayadda/";> or <A HREF="mailto:george_tirebiter@noway.nohow";>
The software will terminate it with a </A> at the right spot.
require PlotCalendar::Month;
my $month = PlotCalendar::Month->new(01,1999); # Jan 1999
# global values, to be applied to all cells
------------------------- size of whole calendar
$month -> size(700,700); # width, height in pixels
------------------------- font sizes for digit, name of day, and text
$month -> font('14','10','8');
------------------------- clip text if it wants to wrap?
$month -> cliptext('yes');
------------------------- This can be any day you want
$month -> firstday('Sun'); # First column is Sunday
------------------------- If this is not set, regular text will be used.
------------------------- If it is set, then in that directory should be
------------------------- gif files named 0.gif, 1.gif ... January.gif, ...
$month -> artwork('/home/ajackson/public_html/cgi-bin/Calendar/Calendar_art3/');
# arrays of values, if not an array, apply to all cells, if an array # apply to each cell, indexed by day-of-month
The colors are the standard values used in html Textstyle encoding is b=bold, i=italic, u=underline, n=normal Fontsize = 6-14, roughly point sizes
my @text;
my @daynames;
my @nameref;
my @bgcolor;
my @colors = ('WHITE','#33cc00','#FF99FF','#FF7070','#FFB0B0',);
my (@textcol,@textsize,@textstyle,@textref);
my @style = ('i','u','b',);
my @url;
----------- build some random color and text fields as a demo
for (my $i=1;$i<=31;$i++) {
$daynames[$i] = "Day number $i";
$nameref[$i] = "<A HREF=\"http://www.$i.ca\">";
$bgcolor[$i] = $colors[$i%5];
@{$text[$i]} = ("Text 1 for $i","Second $i text","$i bit of text",);
@{$textref[$i]} = ("<A HREF=\"http://www.$i.com/\">","Second $i text","<A HREF=\"http://www.$i.net/\">",);
@{$textcol[$i]} = ($colors[($i+1)%5],$colors[($i+2)%5],$colors[($i+3)%5]);
@{$textsize[$i]} = ("8","10","8",);
@{$textstyle[$i]} = @style;
@style = reverse(@style);
$url[$i] = '<A href="http://some.org/name_number_' . $i . '">';
}
------------------------- Set global values
$month -> fgcolor('BLACK',); # Global foreground color
$month -> bgcolor(@bgcolor); # Background color per day
$month -> styles('b','bi','ui',); # Global text styles
# Comments
my @prefs = ('before','after','after');
my @comments = (['Comment one'],["Comment two","and so on"],['Comment three']);
my @comcol = qw(b g b);
my @comstyle = qw(n b bi);
my @comsize = qw(8 10 14);
------------------------- Comments get stuck into an otherwise empty cell $month->comments(\@prefs,\@comments,\@comcol,\@comstyle,\@comsize);
------------------------- Wrap a hotlink around the whole day, for each day $month -> htmlref(@url);
------------------------- set the names for every day $month -> dayname(@daynames); ------------------------- wrap the name in a hotlink $month -> nameref(@nameref);
------------------------- set the text and it's properties for each day $month -> text(@text); $month -> textcolor(@textcol); $month -> textsize(@textsize); $month -> textstyle(@textstyle); $month -> textref(@textref);
# global HTML only options
----------------- allow days to expand vertically to accomodate text
$month -> htmlexpand('yes');
# grab an ascii calendar and print it my $text = $month -> getascii;
print $text;
------------------- get the html calendar
my $html = $month -> gethtml;
print "<HTML><BODY>\n"; print $html;
Also look at Day.pm
PlotCalendar::DateToolsThis is a pure perl replacement for Date::Calc. I needed it because Date::Calc contains C code which my web hosting service did not have available for CGI-BIN stuff.
Alan Jackson March 1999 alan@ajackson.org
require PlotCalendar::DateDesc;
my ($month, $year) = (3,1999);
# ---- set the month and year my $trans = PlotCalendar::DateDesc->new($month, $year);
# ---- parse a description and return the day of the month
my $day = 'first monday and third monday';
print "$day : ",join(',',@{$trans->getdom($day)}),"\n";
$day = 'last monday and third monday';
print "$day : ",join(',',@{$trans->getdom($day)}),"\n";
$day = 'last fri and third Monday';
print "$day : ",join(',',@{$trans->getdom($day)}),"\n";
# ---- parse a description and return the date as mm/dd/yyyy
$day = 'last fri and third Monday';
print "$day dates: ", join(',',@{$trans->getdates($day)}),"\n";
What gets returned by both routines is a pointer to an array of answers
input descriptions may be one of : a day of the week (monday, tuesday, etc) a qualified day of the week (first monday, second tuesday, last sunday) compound statements are allowed : mon and wed, first mon and third mon
Qualifiers are : first, second, third, fourth, fifth, last Compounds are only formed with 'and' and are not associative
Alan Jackson March 1999 alan@ajackson.org
require PlotCalendar::DateTools;
my ($day, $month, $year) = (5,3,1999); my $dayname = 'Tuesday';
# ---- initialize tool
my $dow = Day_of_Year($yr,$mon,$day);
my $numdays = Days_in_Month($yr,$mon);
my $dow = Decode_Day_of_Week($dayname);
my $dowfirst = Day_of_Week($yr,$mon,$day);
my ($nyr, $nmon, $nday) = Add_Delta_Days($yr,$mon,$day, $numdays);
my $dayname = Day_of_Week_to_Text($dow)
my $month = Month_to_Text($mon);
my $doy = Day_of_Year($year,$mon,$day);
A perl-only clone of a subset of Date::Calc
Alan Jackson April 1999 alan@ajackson.org
Requires modules : Exporter Carp Time::DaysInMonth Time::JulianDay
I may be reached at alan@ajackson.org or