Skip to content

Commit

Permalink
Merge pull request #570 from EugenDipner/master
Browse files Browse the repository at this point in the history
19705 fproot
  • Loading branch information
EugenDipner authored Jul 15, 2021
2 parents cc927e0 + 957dd83 commit 571db7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
24 changes: 13 additions & 11 deletions modules/Calendar/actions/SaveAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,19 @@ public function getRecordModelFromRequest(Vtiger_Request $request) {
}
$recordModel->set('visibility', ucfirst($sharedType));
}

$time = (strtotime($endTime))- (strtotime($startTime));
$diffinSec= (strtotime($endDate))- (strtotime($startDate));
$diff_days=floor($diffinSec/(60*60*24));

$hours=((float)$time/3600)+($diff_days*24);
$minutes = ((float)$hours-(int)$hours)*60;

$recordModel->set('duration_hours', (int)$hours);
$recordModel->set('duration_minutes', round($minutes,0));


if (!empty($endTime)) {
// events only
$time = (strtotime($endTime))- (strtotime($startTime));
$diffinSec= (strtotime($endDate))- (strtotime($startDate));
$diff_days=floor($diffinSec/(60*60*24));

$hours=((float)$time/3600)+($diff_days*24);
$minutes = ((float)$hours-(int)$hours)*60;

$recordModel->set('duration_hours', (int)$hours);
$recordModel->set('duration_minutes', round($minutes,0));
}
return $recordModel;
}
}
11 changes: 7 additions & 4 deletions modules/Vtiger/uitypes/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ public static function getTimeValueWithSeconds($time) {
*/
public function getDisplayValue($value, $record = false, $recordInstance = false) {
$userModel = Users_Privileges_Model::getCurrentUserModel();
$dateTimeValueObj = DateTimeField::convertToUserTimeZone($value);
$value = $dateTimeValueObj->format('H:i');
if($userModel->get('hour_format') == '12'){
// exclude UI 63 field with different time format (duration_hours)
if (strpos($value, ':') !== false) {
$dateTimeValueObj = DateTimeField::convertToUserTimeZone($value);
$value = $dateTimeValueObj->format('H:i');
}
if($userModel->get('hour_format') == '12' && strpos($value, ':') !== false){
return self::getTimeValueInAMorPM($value);
}
return $value;
Expand All @@ -118,7 +121,7 @@ public function getDisplayValue($value, $record = false, $recordInstance = false
* @return converted value
*/
public function getEditViewDisplayValue($value) {
$dateTimeValueObj = DateTimeField::convertToUserTimeZone($value);
$dateTimeValueObj = DateTimeField::convertToUserTimeZone($value);
$value = $dateTimeValueObj->format('H:i');
return self::getTimeValueInAMorPM($value);
}
Expand Down

0 comments on commit 571db7d

Please sign in to comment.