fixed shift length display

This commit is contained in:
Philip Häusler 2011-09-29 14:38:23 +02:00
parent 8a5f510da2
commit 402dc172b6
3 changed files with 14 additions and 2 deletions

View File

@ -21,7 +21,7 @@ function user_myshifts() {
return template_render('../templates/user_shifts_add.html', array ( return template_render('../templates/user_shifts_add.html', array (
'angel' => $user['Nick'], 'angel' => $user['Nick'],
'date' => date("Y-m-d H:i", $shift['start']) . ', ' . date("H", $shift['end'] - $shift['start']) . ' h', 'date' => date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift),
'location' => $shift['Name'], 'location' => $shift['Name'],
'title' => $shift['name'], 'title' => $shift['name'],
'type' => $shift['angel_type'], 'type' => $shift['angel_type'],

View File

@ -93,7 +93,8 @@ function user_shifts() {
$user_text = $user['Nick']; $user_text = $user['Nick'];
return template_render('../templates/user_shifts_add.html', array ( return template_render('../templates/user_shifts_add.html', array (
'date' => date("Y-m-d H:i", $shift['start']) . ', ' . date("H:i", $shift['end'] - $shift['start']) . 'h', //'date' => date("Y-m-d H:i", $shift['start']) . ', ' . date("H:i", $shift['end'] - $shift['start']) . 'h',
'date' => date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift),
'title' => $shift['name'], 'title' => $shift['name'],
'location' => $shift['Name'], 'location' => $shift['Name'],
'angel' => $user_text, 'angel' => $user_text,

View File

@ -1,4 +1,15 @@
<?php <?php
/**
* Shiftlänge ausrechnen, kommt im Format 12:23h zurück
*/
function shift_length($shift) {
$length = round(($shift['end'] - $shift['start']) / (60 * 60), 0) . ":";
$length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, "0", STR_PAD_LEFT) . "h";
return $length;
}
function load_shift_basics() { function load_shift_basics() {
global $VeranstaltungsTageMax, $Room, $RoomID, $EngelType, $EngelTypeID, $TID2Name, $Veranstaltungstage; global $VeranstaltungsTageMax, $Room, $RoomID, $EngelType, $EngelTypeID, $TID2Name, $Veranstaltungstage;