MDL-52355 mod_data: Added Gregorian hour and minute values
authorJun Pataleta <jun@moodle.com>
Wed, 23 Dec 2015 01:45:42 +0000 (09:45 +0800)
committerJun Pataleta <jun@moodle.com>
Wed, 23 Dec 2015 01:53:12 +0000 (09:53 +0800)
mod/data/field/date/field.class.php

index 083d648..600e0e9 100644 (file)
@@ -47,7 +47,15 @@ class data_field_date extends data_field_base {
 
             $calendartype = \core_calendar\type_factory::get_calendar_instance();
             $gregoriandate = $calendartype->convert_to_gregorian($year, $month, $day);
-            $content = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], 12, 0, 0, 0, false);
+            $content = make_timestamp(
+                $gregoriandate['year'],
+                $gregoriandate['month'],
+                $gregoriandate['day'],
+                $gregoriandate['hour'],
+                $gregoriandate['minute'],
+                0,
+                0,
+                false);
         } else if ($recordid) {
             $content = (int)$DB->get_field('data_content', 'content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid));
         } else {
@@ -95,8 +103,15 @@ class data_field_date extends data_field_base {
             $calendartype = \core_calendar\type_factory::get_calendar_instance();
             $gregoriandate = $calendartype->convert_to_gregorian($year, $month, $day);
 
-            $data['timestamp'] = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'],
-                    12, 0, 0, 0, false);
+            $data['timestamp'] = make_timestamp(
+                $gregoriandate['year'],
+                $gregoriandate['month'],
+                $gregoriandate['day'],
+                $gregoriandate['hour'],
+                $gregoriandate['minute'],
+                0,
+                0,
+                false);
             $data['usedate'] = 1;
             return $data;
         } else {
@@ -120,8 +135,15 @@ class data_field_date extends data_field_base {
 
             $calendartype = \core_calendar\type_factory::get_calendar_instance();
             $gregoriandate = $calendartype->convert_to_gregorian($this->year, $this->month, $this->day);
-            $content->content = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'],
-                    12, 0, 0, 0, false);
+            $content->content = make_timestamp(
+                $gregoriandate['year'],
+                $gregoriandate['month'],
+                $gregoriandate['day'],
+                $gregoriandate['hour'],
+                $gregoriandate['minute'],
+                0,
+                0,
+                false);
 
             if ($oldcontent = $DB->get_record('data_content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))) {
                 $content->id = $oldcontent->id;