Budget graph in project details (#3406)

* do not copy description if restarting via calendar
* added support to display negative durations
* fix charts for larger numbers
This commit is contained in:
Kevin Papst
2022-07-13 17:21:36 +02:00
committed by GitHub
parent 245dd47082
commit 0dba83d8e9
26 changed files with 400 additions and 80 deletions

View File

@@ -22,8 +22,10 @@ class Duration
* @deprecated since 1.13
*/
public const FORMAT_SECONDS = 'seconds';
public const FORMAT_WITH_SECONDS = '%h:%m:%s';
/**
* @deprecated since 1.21
*/
public const FORMAT_WITH_SECONDS = '%h:%m';
public const FORMAT_NO_SECONDS = '%h:%m';
/**
@@ -39,19 +41,21 @@ class Duration
return null;
}
if ($seconds < 0) {
if ($seconds <= -60) {
$format = '-' . $format;
}
$seconds = abs($seconds);
}
$hour = (int) floor($seconds / 3600);
$minute = (int) floor((int) ($seconds / 60) % 60);
$hour = $hour > 9 ? $hour : '0' . $hour;
$minute = $minute > 9 ? $minute : '0' . $minute;
$second = $seconds % 60;
$second = $second > 9 ? $second : '0' . $second;
$formatted = str_replace('%h', $hour, $format);
$formatted = str_replace('%m', $minute, $formatted);
return str_replace('%s', $second, $formatted);
return str_replace('%m', $minute, $formatted);
}
/**

View File

@@ -122,10 +122,6 @@ final class LocaleFormatter
private function formatDuration(int $seconds, string $format): string
{
if ($seconds < 0) {
return '?';
}
return $this->durationFormatter->format($seconds, $format);
}