Permalink
Browse files

Replaced some nasty 'magic numbers' with defines.

  • Loading branch information...
1 parent fbf5f5c commit 282cd5aec2cc3260d3ca706060a8f24c3261270f thepurpleblob committed Apr 2, 2008
Showing with 17 additions and 6 deletions.
  1. +9 −3 course/format/weeks/format.php
  2. +8 −3 course/format/weekscss/format.php
@@ -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];
@@ -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];

0 comments on commit 282cd5a

Please sign in to comment.