CC-5594 : Remove all date_default_timezone_get()
using the user selected timezone in the form to calculate duration.
This commit is contained in:
parent
c732b44903
commit
39063aaadb
|
@ -630,9 +630,12 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function calculateDurationAction()
|
public function calculateDurationAction()
|
||||||
{
|
{
|
||||||
|
$start = $this->_getParam('startTime');
|
||||||
|
$end = $this->_getParam('endTime');
|
||||||
|
$timezone = $this->_getParam('timezone');
|
||||||
|
|
||||||
$service_showForm = new Application_Service_ShowFormService();
|
$service_showForm = new Application_Service_ShowFormService();
|
||||||
$result = $service_showForm->calculateDuration($this->_getParam('startTime'),
|
$result = $service_showForm->calculateDuration($start, $end, $timezone);
|
||||||
$this->_getParam('endTime'));
|
|
||||||
|
|
||||||
echo Zend_Json::encode($result);
|
echo Zend_Json::encode($result);
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -470,11 +470,13 @@ class Application_Service_ShowFormService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateDuration($start, $end)
|
public function calculateDuration($start, $end, $timezone)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$startDateTime = new DateTime($start);
|
|
||||||
$endDateTime = new DateTime($end);
|
$tz = new DateTimeZone($timezone);
|
||||||
|
$startDateTime = new DateTime($start, $tz);
|
||||||
|
$endDateTime = new DateTime($end, $tz);
|
||||||
|
|
||||||
$duration = $startDateTime->diff($endDateTime);
|
$duration = $startDateTime->diff($endDateTime);
|
||||||
|
|
||||||
|
@ -490,6 +492,7 @@ class Application_Service_ShowFormService
|
||||||
return $duration->format('%r%Hh %Im');
|
return $duration->format('%r%Hh %Im');
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
Logging::info($e->getMessage());
|
||||||
return "Invalid Date";
|
return "Invalid Date";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,7 +687,8 @@ function setAddShowEvents(form) {
|
||||||
// calculate duration
|
// calculate duration
|
||||||
var startDateTimeString = startDateString + " " + startTimeString;
|
var startDateTimeString = startDateString + " " + startTimeString;
|
||||||
var endDateTimeString = $('#add_show_end_date_no_repeat').val() + " " + $('#add_show_end_time').val();
|
var endDateTimeString = $('#add_show_end_date_no_repeat').val() + " " + $('#add_show_end_time').val();
|
||||||
calculateDuration(startDateTimeString, endDateTimeString);
|
var timezone = $("#add_show_timezone").val();
|
||||||
|
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -718,7 +719,8 @@ function setAddShowEvents(form) {
|
||||||
// calculate duration
|
// calculate duration
|
||||||
var startDateTimeString = startDateString + " " + startTimeString;
|
var startDateTimeString = startDateString + " " + startTimeString;
|
||||||
var endDateTimeString = endDateString + " " + endTimeString;
|
var endDateTimeString = endDateString + " " + endTimeString;
|
||||||
calculateDuration(startDateTimeString, endDateTimeString);
|
var timezone = $("#add_show_timezone").val();
|
||||||
|
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -736,11 +738,14 @@ function setAddShowEvents(form) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function calculateDuration(startDateTime, endDateTime){
|
function calculateDuration(startDateTime, endDateTime, timezone){
|
||||||
var loadingIcon = $('#icon-loader-small');
|
var loadingIcon = $('#icon-loader-small');
|
||||||
|
|
||||||
loadingIcon.show();
|
loadingIcon.show();
|
||||||
$.post(baseUrl+"Schedule/calculate-duration", {startTime: startDateTime, endTime: endDateTime}, function(data){
|
$.post(
|
||||||
|
baseUrl+"Schedule/calculate-duration",
|
||||||
|
{startTime: startDateTime, endTime: endDateTime, timezone: timezone},
|
||||||
|
function(data) {
|
||||||
$('#add_show_duration').val(JSON.parse(data));
|
$('#add_show_duration').val(JSON.parse(data));
|
||||||
loadingIcon.hide();
|
loadingIcon.hide();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue