From: martin <martin>
Date: Mon, 29 Jul 2002 15:10:21 +0000 (+0000)
Subject: Much simpler date-setting using new moodlelib functions
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9690be38ff4df91945ba14e7f1b241b7bd68beec;p=moodle.git

Much simpler date-setting using new moodlelib functions
---

diff --git a/course/edit.html b/course/edit.html
index df42847191..8cc7758afb 100644
--- a/course/edit.html
+++ b/course/edit.html
@@ -86,9 +86,7 @@
 <tr valign=top>
 	<td><P><? print_string("startdate") ?>:</td>
 	<td><?
-           choose_from_menu ($form->days, "startday", "$form->startday");
-           choose_from_menu ($form->months, "startmonth", "$form->startmonth");
-           choose_from_menu ($form->years, "startyear", "$form->startyear");
+           print_date_selector("startday", "startmonth", "startyear", $form->startdate);
 	       formerr($err["startdate"]);
 	?></td>
 </tr>
diff --git a/course/edit.php b/course/edit.php
index 96ec7a1c97..674bc674eb 100644
--- a/course/edit.php
+++ b/course/edit.php
@@ -34,7 +34,7 @@
 
         $form = (object)$HTTP_POST_VARS;
 
-        $form->startdate = mktime(0,0,0,(int)$form->startmonth,(int)$form->startday,(int)$form->startyear);
+        $form->startdate = make_timestamp($form->startyear, $form->startmonth, $form->startday);
 
         validate_form($course, $form, $err);
 
@@ -79,9 +79,8 @@
     if (!$form) {
         if ($course) {
             $form = $course;
-            $ts = getdate($course->startdate);
         } else {
-            $ts = getdate(time() + 3600 * 24);
+            $form->startdate = time() + 3600 * 24;
             $form->teacher = "Facilitator";
             $form->student = "Student";
             $form->fullname = "Course Fullname 101";
@@ -92,30 +91,10 @@
             $form->newsitems = 5;
             $form->category = 1;
         }
-
-        $form->startday = $ts[mday];
-        $form->startmonth = $ts[mon];
-        $form->startyear = $ts[year];
-
-        $form->endday = $te[mday];
-        $form->endmonth = $te[mon];
-        $form->endyear = $te[year];
-    }
-
-    for ($i=1;$i<=31;$i++) {
-        $form->days[$i] = "$i";
-    }
-    for ($i=1;$i<=12;$i++) {
-        $form->months[$i] = date("F", mktime(0,0,0,$i,1,2000));
-    }
-    for ($i=2000;$i<=2010;$i++) {
-        $form->years[$i] = $i;
     }
 
     $form->categories = get_records_sql_menu("SELECT id,name FROM course_categories");
 
-    //$form->owners   = get_records_sql_menu("SELECT u.id, CONCAT(u.firstname, " ", u.lastname) FROM users u, teachers t WHERE t.user = u.id");
-
     $editcoursesettings = get_string("editcoursesettings");
 
     if (isset($course)) {