Permalink
Browse files

MDL-27562 formslib: Timezone option is passed to usergetdate for date…

…selector and datetimeselector form element
  • Loading branch information...
1 parent e16e230 commit fa70f635229af8dec5082054036ba7dfc9579756 Rajesh Taneja committed May 4, 2012
Showing with 10 additions and 4 deletions.
  1. +5 −2 lib/form/dateselector.php
  2. +5 −2 lib/form/datetimeselector.php
@@ -45,7 +45,10 @@ class MoodleQuickForm_date_selector extends MoodleQuickForm_group
* Control the fieldnames for form elements
* startyear => int start of range of years that can be selected
* stopyear => int last year that can be selected
- * timezone => float/string timezone
+ * timezone => int|float|string (optional) timezone modifier used for edge case only.
+ * If not specified, then date is caclulated based on current user timezone.
+ * Note: dst will be calculated for string timezones only
+ * {@link http://docs.moodle.org/dev/Time_API#Timezone}
* applydst => apply users daylight savings adjustment?
* optional => if true, show a checkbox beside the date to turn it on (or off)
* @var array
@@ -147,7 +150,7 @@ function onQuickFormEvent($event, $arg, &$caller)
$value = time();
}
if (!is_array($value)) {
- $currentdate = usergetdate($value);
+ $currentdate = usergetdate($value, $this->_options['timezone']);
$value = array(
'day' => $currentdate['mday'],
'month' => $currentdate['mon'],
@@ -45,7 +45,10 @@ class MoodleQuickForm_date_time_selector extends MoodleQuickForm_group{
* startyear => int start of range of years that can be selected
* stopyear => int last year that can be selected
* defaulttime => default time value if the field is currently not set
- * timezone => float/string timezone
+ * timezone => int|float|string (optional) timezone modifier used for edge case only.
+ * If not specified, then date is caclulated based on current user timezone.
+ * Note: dst will be calculated for string timezones only
+ * {@link http://docs.moodle.org/dev/Time_API#Timezone}
* applydst => apply users daylight savings adjustment?
* step => step to increment minutes by
* optional => if true, show a checkbox beside the date to turn it on (or off)
@@ -164,7 +167,7 @@ function onQuickFormEvent($event, $arg, &$caller)
}
}
if (!is_array($value)) {
- $currentdate = usergetdate($value);
+ $currentdate = usergetdate($value, $this->_options['timezone']);
// Round minutes to the previous multiple of step.
$currentdate['minutes'] -= $currentdate['minutes'] % $this->_options['step'];
$value = array(

0 comments on commit fa70f63

Please sign in to comment.