diff --git a/CHANGELOG.md b/CHANGELOG.md index 150143a..34d7700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fixed parsing regex for Toggl entries. +- Fixed duration formatting when the duration is higher than one day. + ## [1.2.0] - 2023-10-13 ### Added diff --git a/src/Client/Toggl/TogglClient.php b/src/Client/Toggl/TogglClient.php index 6418063..5aebe14 100644 --- a/src/Client/Toggl/TogglClient.php +++ b/src/Client/Toggl/TogglClient.php @@ -106,7 +106,7 @@ function (array $entry) use ($filters, $logger): ?Entry { */ private function createEntry(array $entry, array $filters, LoggerInterface $logger): ?Entry { - $parsed = false !== (bool) preg_match('/^(?[a-zA-Z]+-\d+)( +)?(?.*)?$/', $entry['description'], $m); + $parsed = false !== (bool) preg_match('/^(?[a-zA-Z\-\d]+)( +)?(?.*)?$/', $entry['description'], $m); $stop = $entry['stop'] ?? null; if (!$parsed || !isset($m['ISSUE'], $m['DESCRIPTION'])) { diff --git a/src/Helper/DurationFormatter.php b/src/Helper/DurationFormatter.php index a8e7d08..c11cbeb 100644 --- a/src/Helper/DurationFormatter.php +++ b/src/Helper/DurationFormatter.php @@ -27,6 +27,11 @@ public static function format(int $seconds): string $interval = $start->diff($end); $hours = $interval->h; + + if (false !== $interval->days) { + $hours += 24 * $interval->days; + } + $minutes = $interval->i; return 0 < $hours ? ($hours . 'h ' . $minutes . 'm') : ($minutes . 'm');