// minutesToDuration converts an integer number of minutes into duration string.
// Formats returned HH:MM, HHH:MM, HH, or HHH.
static function minutesToDuration($minutes, $abbreviate = false) {
- $sign = $minutes > 0 ? '' : '-';
+ $sign = $minutes >= 0 ? '' : '-';
$minutes = abs($minutes);
$hours = (string) (int)($minutes / 60);
// toMinutes - converts a time string in format 00:00 to a number of minutes.
static function toMinutes($value) {
+ $signMultiplier = ttStartsWith($value, '-') ? -1 : 1;
+ if ($signMultiplier == -1) $duration = ltrim($duration, '-');
+
$time_a = explode(':', $value);
- return (int)@$time_a[1] + ((int)@$time_a[0]) * 60;
+ return $signMultiplier * ((int)@$time_a[1] + ((int)@$time_a[0]) * 60);
}
// toAbsDuration - converts a number of minutes to format 0:00
}
// getRecords - returns time records for a user for a given date.
- static function getRecords($user_id, $date) {
+ static function getRecords($date) {
// TODO: merge getRecords and getRecordsWithFiles into one function.
global $user;
$mdb2 = getConnection();
+ $user_id = $user->getUser();
$group_id = $user->getGroup();
$org_id = $user->org_id;
// getRecordsWithFiles - returns time records for a user for a given date
// with information whether they have attached files (has_files property).
// A separate fiunction from getRecords because sql here is more complex.
- static function getRecordsWithFiles($user_id, $date) {
+ static function getRecordsWithFiles($date) {
global $user;
$mdb2 = getConnection();
+ $user_id = $user->getUser();
$group_id = $user->getGroup();
$org_id = $user->org_id;