From c961269bb718cfc5b5889af88fd12bfc86563d09 Mon Sep 17 00:00:00 2001 From: msquare Date: Sat, 30 Dec 2017 12:07:10 +0100 Subject: [PATCH] better hour formatting --- includes/controller/users_controller.php | 2 +- includes/pages/admin_active.php | 2 +- includes/view/PublicDashboard_view.php | 2 +- includes/view/User_view.php | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index c763cd48..8a325621 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -228,7 +228,7 @@ function user_controller() if($user_source['force_active']) { $tshirt_score = _('Enough'); } else { - $tshirt_score = round(User_tshirt_score($user_source), 2) . ' h'; + $tshirt_score = sprintf('%.2f', User_tshirt_score($user_source)) . ' h'; } return [ diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index f3a28061..6a9e96ce 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -182,7 +182,7 @@ function admin_active() $usr['nick'] = User_Nick_render($usr); $usr['shirt_size'] = $tshirt_sizes[$usr['Size']]; $usr['work_time'] = round($usr['shift_length'] / 60) - . ' min (' . round($usr['shift_length'] / 3600) . ' h)'; + . ' min (' . sprintf('%.2f', $usr['shift_length'] / 3600) . ' h)'; $usr['active'] = glyph_bool($usr['Aktiv'] == 1); $usr['force_active'] = glyph_bool($usr['force_active'] == 1); $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1); diff --git a/includes/view/PublicDashboard_view.php b/includes/view/PublicDashboard_view.php index 83cf0e5f..6fef8f54 100644 --- a/includes/view/PublicDashboard_view.php +++ b/includes/view/PublicDashboard_view.php @@ -68,7 +68,7 @@ function public_dashboard_view($stats, $free_shifts) function public_dashboard_shift_render($shift) { $panel_body = glyph('time') . $shift['start'] . ' - ' . $shift['end']; - $panel_body .= ' (' . $shift['duration'] . ' h)'; + $panel_body .= ' (' . $shift['duration'] . ' h)'; $panel_body .= '
' . glyph('tasks') . $shift['shifttype_name']; if (!empty($shift['title'])) { diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 4dc78f05..745bc6d5 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -356,7 +356,7 @@ function User_view_myshift($shift, $user_source, $its_me) . glyph('time') . date('H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']), - 'duration' => sprintf('%.2f', round(($shift['end'] - $shift['start']) / 3600, 2)) . ' h', + 'duration' => sprintf('%.2f', ($shift['end'] - $shift['start']) / 3600) . ' h', 'room' => Room_name_render($shift), 'shift_info' => $shift_info, 'comment' => '' @@ -368,7 +368,7 @@ function User_view_myshift($shift, $user_source, $its_me) if ($shift['freeloaded']) { $myshift['duration'] = '

' - . round(-($shift['end'] - $shift['start']) / 3600 * 2, 2) . ' h' + . round(-($shift['end'] - $shift['start']) / 3600 * 2, 2) . ' h' . '

'; if (in_array('user_shifts_admin', $privileges)) { $myshift['comment'] .= '
' @@ -431,7 +431,7 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi ksort($myshifts_table); $myshifts_table[] = [ 'date' => '' . _('Sum:') . '', - 'duration' => '' . sprintf('%.2f', round($timesum / 3600, 2)) . ' h', + 'duration' => '' . sprintf('%.2f', round($timesum / 3600, 2)) . ' h', 'room' => '', 'shift_info' => '', 'comment' => '', @@ -440,7 +440,7 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi if (config('enable_tshirt_size', false) && ($its_me || $tshirt_admin)) { $myshifts_table[] = [ 'date' => '' . _('Your t-shirt score') . '™:', - 'duration' => '' . sprintf('%.2f', $tshirt_score) . ' h', + 'duration' => '' . $tshirt_score . '', 'room' => '', 'shift_info' => '', 'comment' => '', @@ -475,7 +475,7 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) { return [ 'date' => glyph('calendar') . date('Y-m-d', $worklog['work_timestamp']), - 'duration' => '' . sprintf('%.2f', $worklog['work_hours']) . ' h', + 'duration' => '' . sprintf('%.2f', $worklog['work_hours']) . '', 'room' => '', 'shift_info' => _('Work log entry'), 'comment' => $worklog['comment'] . '
'