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()
|
||||
{
|
||||
$start = $this->_getParam('startTime');
|
||||
$end = $this->_getParam('endTime');
|
||||
$timezone = $this->_getParam('timezone');
|
||||
|
||||
$service_showForm = new Application_Service_ShowFormService();
|
||||
$result = $service_showForm->calculateDuration($this->_getParam('startTime'),
|
||||
$this->_getParam('endTime'));
|
||||
$result = $service_showForm->calculateDuration($start, $end, $timezone);
|
||||
|
||||
echo Zend_Json::encode($result);
|
||||
exit();
|
||||
|
|
|
@ -470,11 +470,13 @@ class Application_Service_ShowFormService
|
|||
}
|
||||
}
|
||||
|
||||
public function calculateDuration($start, $end)
|
||||
public function calculateDuration($start, $end, $timezone)
|
||||
{
|
||||
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);
|
||||
|
||||
|
@ -490,6 +492,7 @@ class Application_Service_ShowFormService
|
|||
return $duration->format('%r%Hh %Im');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Logging::info($e->getMessage());
|
||||
return "Invalid Date";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -687,7 +687,8 @@ function setAddShowEvents(form) {
|
|||
// calculate duration
|
||||
var startDateTimeString = startDateString + " " + startTimeString;
|
||||
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
|
||||
var startDateTimeString = startDateString + " " + startTimeString;
|
||||
var endDateTimeString = endDateString + " " + endTimeString;
|
||||
calculateDuration(startDateTimeString, endDateTimeString);
|
||||
var timezone = $("#add_show_timezone").val();
|
||||
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -736,13 +738,16 @@ function setAddShowEvents(form) {
|
|||
}
|
||||
})
|
||||
|
||||
function calculateDuration(startDateTime, endDateTime){
|
||||
function calculateDuration(startDateTime, endDateTime, timezone){
|
||||
var loadingIcon = $('#icon-loader-small');
|
||||
|
||||
loadingIcon.show();
|
||||
$.post(baseUrl+"Schedule/calculate-duration", {startTime: startDateTime, endTime: endDateTime}, function(data){
|
||||
$('#add_show_duration').val(JSON.parse(data));
|
||||
loadingIcon.hide();
|
||||
$.post(
|
||||
baseUrl+"Schedule/calculate-duration",
|
||||
{startTime: startDateTime, endTime: endDateTime, timezone: timezone},
|
||||
function(data) {
|
||||
$('#add_show_duration').val(JSON.parse(data));
|
||||
loadingIcon.hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue