diff -Naur moodle-clean/moodle/lib/form/dateselector.php moodle/lib/form/dateselector.php
--- moodle-clean/moodle/lib/form/dateselector.php 2007-04-14 03:10:30.000000000 +0100
+++ moodle/lib/form/dateselector.php 2008-12-10 10:44:55.000000000 +0000
@@ -68,7 +68,7 @@
{
$this->_elements = array();
for ($i=1; $i<=31; $i++) {
- $days[$i] = $i;
+ $days[$i] = userdate(gmmktime(12,0,0,date('m'),$i), "%a").' '.$i;
}
for ($i=1; $i<=12; $i++) {
$months[$i] = userdate(gmmktime(12,0,0,$i,15,2000), "%B");
@@ -76,9 +76,11 @@
for ($i=$this->_options['startyear']; $i<=$this->_options['stopyear']; $i++) {
$years[$i] = $i;
}
- $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true);
- $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true);
- $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true);
+ global$CFG;
+ $randid=rand();
+ $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes().'id="'.$randid.'day"', true);
+ $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes().'id="'.$randid.'month" onChange="WeekDays('.$randid.')"', true);
+ $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes().'id="'.$randid.'year" onChange="WeekDays('.$randid.')"', true);
// If optional we add a checkbox which the user can use to turn if on
if($this->_options['optional']) {
$this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true);
@@ -88,6 +90,8 @@
$element->setHiddenLabel(true);
}
}
+ require_js($CFG->wwwroot.'/lib/form/weekdays.js');
+ // cant echo it here- form isnt loaded yet :( echo''."\n";
}
diff -Naur moodle-clean/moodle/lib/form/datetimeselector.php moodle/lib/form/datetimeselector.php
--- moodle-clean/moodle/lib/form/datetimeselector.php 2007-08-09 17:56:36.000000000 +0100
+++ moodle/lib/form/datetimeselector.php 2008-12-10 10:45:01.000000000 +0000
@@ -67,7 +67,7 @@
{
$this->_elements = array();
for ($i=1; $i<=31; $i++) {
- $days[$i] = $i;
+ $days[$i] = userdate(gmmktime(12,0,0,date('m'),$i), "%a").' '.$i;
}
for ($i=1; $i<=12; $i++) {
$months[$i] = userdate(gmmktime(12,0,0,$i,15,2000), "%B");
@@ -81,9 +81,11 @@
for ($i=0; $i<60; $i+=$this->_options['step']) {
$minutes[$i] = sprintf("%02d",$i);
}
- $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true);
- $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true);
- $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true);
+ global$CFG;
+ $randid=rand();
+ $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes().'id="'.$randid.'day"', true);
+ $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes().'id="'.$randid.'month" onChange="WeekDays('.$randid.')"', true);
+ $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes().'id="'.$randid.'year" onChange="WeekDays('.$randid.')"', true);
if (right_to_left()) { // Switch order of elements for Right-to-Left
$this->_elements[] =& MoodleQuickForm::createElement('select', 'minute', get_string('minute', 'form'), $minutes, $this->getAttributes(), true);
$this->_elements[] =& MoodleQuickForm::createElement('select', 'hour', get_string('hour', 'form'), $hours, $this->getAttributes(), true);
@@ -100,7 +102,9 @@
$element->setHiddenLabel(true);
}
}
-
+ require_js($CFG->wwwroot.'/lib/form/weekdays.js');
+ // cant echo it here- form isnt loaded yet :( echo''."\n";
+
}
// }}}
diff -Naur moodle-clean/moodle/lib/form/weekdays.js moodle/lib/form/weekdays.js
--- moodle-clean/moodle/lib/form/weekdays.js 1970-01-01 01:00:00.000000000 +0100
+++ moodle/lib/form/weekdays.js 2008-12-10 10:45:22.000000000 +0000
@@ -0,0 +1,25 @@
+function WeekDays(randid){
+ daySelect=document.getElementById(randid+"day");
+ monthSelect=document.getElementById(randid+"month");
+ yearSelect=document.getElementById(randid+"year");
+
+ month=(monthSelect.selectedIndex +1);
+ year=yearSelect.options[yearSelect.selectedIndex].value;
+
+ var weekday=new Array(7);
+ weekday[0]="Sun";
+ weekday[1]="Mon";
+ weekday[2]="Tue";
+ weekday[3]="Wed";
+ weekday[4]="Thu";
+ weekday[5]="Fri";
+ weekday[6]="Sat";
+
+ for (var i = 0; daySelect[i] != null; i++) {
+ day=i+1;
+ var d=new Date(Date.parse(month+"/"+day+"/"+year));
+ daySelect[i].text=weekday[d.getDay()]+" "+(i+1);
+
+ //document.write("Today it is " + weekday[d.getDay()]);
+ }
+}
\ No newline at end of file