in reply to Unusual report
based on the date how do I get the day of the week and display it.
That is, when the user asks to start the calendar at January 3, 2005, how do you know what day of th eweek that falls on so as to correctly format your calendar?
You need the Perl moduleDATE::CALC
which has the functions:
So you can do, (pseudo code):#returns the week number of the date input $week = Week_of_Year($year,$month,$day); #returns the date of the monday of the week input ($year,$month,$day) = Monday_of_Week($week,$year);
- get $begin_day, $begin_month, $begin_year and $end_day, $end_month, +$end_year from form input $begin_week = Week_of_Year($begin_year,$begin_month,$begin_day); ($begin_year,$begin_month,$begin_monday) = Monday_of_Week($begin_week, +$begin_year); $end_week = Week_of_Year($end_year,$end_month,$end_day); ($end_year,$end_month,$end_monday) = Monday_of_Week($end_week,$end_yea +r); #note that in above month and year get changed in case the range strad +dles months or years - calculate $number_of_weeks in range either using a Date::Calc functi +on or $end_week - $begin week $monday_date = $begin_monday; for $w (1 .. $number_of_weeks) { print days-of-week row; print dates row starting at $monday_date for $r (1 .. $number_of_rooms) { get room data and print it; } $monday_date = $monday_date +7; }
Forget that fear of gravity,
Get a little savagery in your life.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |