Replaced some nasty 'magic numbers' with defines.

This commit is contained in:
thepurpleblob
2008-04-02 13:57:56 +00:00
parent fbf5f5c483
commit 282cd5aec2
2 changed files with 17 additions and 6 deletions
+9 -3
View File
@@ -17,6 +17,12 @@
define('BLOCK_L_MAX_WIDTH', $lmax);
define('BLOCK_R_MIN_WIDTH', $rmin);
define('BLOCK_R_MAX_WIDTH', $rmax);
// some defines for time periods (all are seconds)
define( 'SECONDS_ONEWEEK', 604800 );
define( 'SECONDS_SIXDAYS', 518400 );
define( 'SECONDS_TWOHOURS', 7200 );
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
BLOCK_L_MAX_WIDTH);
@@ -133,10 +139,10 @@
$timenow = time();
$weekdate = $course->startdate; // this should be 0:00 Monday of that week
$weekdate += 7200; // Add two hours to avoid possible DST problems
$weekdate += SECONDS_TWOHOURS; // Add two hours to avoid possible DST problems
$section = 1;
$sectionmenu = array();
$weekofseconds = 604800;
$weekofseconds = SECONDS_ONEWEEK;
$course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
$strftimedateshort = ' '.get_string('strftimedateshort');
@@ -145,7 +151,7 @@
$nextweekdate = $weekdate + ($weekofseconds);
$weekday = userdate($weekdate, $strftimedateshort);
$endweekday = userdate($weekdate+518400, $strftimedateshort);
$endweekday = userdate($weekdate+SECONDS_SIXDAYS, $strftimedateshort);
if (!empty($sections[$section])) {
$thissection = $sections[$section];
+8 -3
View File
@@ -25,6 +25,11 @@
*/
//TODO (nfreear): Accessibility: evaluation, lang/en_utf8/moodle.php: $string['formatweekscss']
// some defines for time periods (all are seconds)
define( 'SECONDS_ONEWEEK', 604800 );
define( 'SECONDS_SIXDAYS', 518400 );
define( 'SECONDS_TWOHOURS', 7200 );
$week = optional_param('week', -1, PARAM_INT);
if ($week != -1) {
@@ -141,10 +146,10 @@
$timenow = time();
$weekdate = $course->startdate; // this should be 0:00 Monday of that week
$weekdate += 7200; // Add two hours to avoid possible DST problems
$weekdate += SECONDS_TWOHOURS; // Add two hours to avoid possible DST problems
$section = 1;
$sectionmenu = array();
$weekofseconds = 604800;
$weekofseconds = SECONDS_ONEWEEK;
$course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
$strftimedateshort = ' '.get_string('strftimedateshort');
@@ -153,7 +158,7 @@
$nextweekdate = $weekdate + ($weekofseconds);
$weekday = userdate($weekdate, $strftimedateshort);
$endweekday = userdate($weekdate+518400, $strftimedateshort);
$endweekday = userdate($weekdate+SECONDS_SIXDAYS, $strftimedateshort);
if (!empty($sections[$section])) {
$thissection = $sections[$section];