Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Making a Calendar in Perl?

by Anonymous Monk
on Jun 22, 2005 at 01:27 UTC ( #468882=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I was wondering what would be the best way to generate a HTML calendar display using Perl. I looked at some modules and came across HTML::Calender::Simple, which looks to be what I want but I'm not 100 sure. Does anyone have any suggestions to other modules or other ways to carry out this task?

My question may be to vague? Basically I want to generate a HTML code that comes out looking like a calendar, boxes for each day, and the basic "Su M T W Th F S" on top. I made a script that adds information for a certain day and would like to generate this calendar to display information. For example, info that is inputted for day 6/23/05, the Thursday box for 23 for June would be marked and a link to a popup displaying the info inputted.

Thanks, AM

Comment on Making a Calendar in Perl?
Re: Making a Calendar in Perl?
by bradcathey (Prior) on Jun 22, 2005 at 02:10 UTC

    I rolled my own, but have you even tried HTML::Calendar::Simple yet? I'd try it first and see if it answers your own question and solves your problem.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: Making a Calendar in Perl?
by gryphon (Abbot) on Jun 22, 2005 at 02:34 UTC

    Greetings Anonymous Monk,

    From what you describe in your post, I think HTML::Calender::Simple would be perfect. The whole $type/$info thing for date events didn't work for me, so I ended up just writing a simple subroutine to handle the link creation myself, then passed that into the daily_info method.

    use strict; use warnings; use CGI; use HTML::Calendar::Simple; my $cgi = CGI->new; print $cgi->header; my $cal = HTML::Calendar::Simple->new({ 'month' => 6, 'year' => 2005, }); sub _display_events { my $events = shift; return join('<br/>', map { $cgi->a({ href => $_->[0] }, $_->[1]) } (@{$events})); } $cal->daily_info({ 'day' => 21, 'events' => _display_events([ ['http://perlmonks.org', 'PerlMonks'], ['http://whitepages.com', 'Whitepages'] ]), }); print $cal->calendar_month;

    gryphon
    Whitepages.com Development Manager (DSMS)
    code('Perl') || die;

Re: Making a Calendar in Perl?
by GrandFather (Cardinal) on Jun 22, 2005 at 02:43 UTC

    Looks pretty easy to me:

    Update: The join/split in the print is not required, it breaks up the output a little though to make it easier to check.


    Perl is Huffman encoded by design.
Re: Making a Calendar in Perl?
by mojotoad (Monsignor) on Jun 22, 2005 at 16:49 UTC
    You might be interested in my HTML::CalendarMonth. It supports many locales and a variety of date computation sources: Time::Local, DateTime, Date::Calc, Date::Manip, and the unix 'cal' command.

    basic usage:

    $c = HTML::CalendarMonth->new( month => 10, year => 1980 ); print $c->as_HTML;

    It's actually a tree structure made of HTML::Element nodes, so if you're using that it's a natural fit. You can alter the attributes or add/change content to each node before generating the HTML.

    Cheers,
    Matt

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://468882]
Approved by graff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-10-22 22:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (122 votes), past polls