Hello. I would like to create a calendar using perl programming. The program should accept the year input by user and also the the day of the week for January 1 of that particular year (1=sunday; 7=saturday). example if i key in 1 for the day input, Jan 1 should be in sunday; if i key in 2, Jan 1 should be monday.
I've looked through the calendar examples in this website but it's too hard for me, especially the use of local time function..I need some help here, below it's the guideline given by my lecturer, which i don't think it's gonna work..
<code>
foreach (1..12) { #12 months
if (day==1) { #if it's sunday
print "\t\t\t\t\t\t\t1\n";
$date=2; #next date will start with 2
}
}
foreach (1..5) { # 5 weeks in a month
foreach (1..7) { #7 days in a week
print "\t$date";
$date++;
print "\n\n";
}
}
if (day=2) { # if it's a monday
print "1\t2\t3\t4\t5\t6\t7\n";
$date=8;
.......#continue to type for 7 days
<code>
i know this program looks stupid but I do really need help with this. How to write codes so that the days do not exceed 28/29/30/31 days per month? and also leap year?? and how to decide the next day for the next new month?? thanks for anyone who help!! (sorry i dunno the html formatting)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.