diff --git a/src/DateTimeFormatter.php b/src/DateTimeFormatter.php index 2203326..6556287 100644 --- a/src/DateTimeFormatter.php +++ b/src/DateTimeFormatter.php @@ -76,9 +76,10 @@ public function formatDuration(float $seconds, string $locale = null): string return $this->translator->trans($format[1], ['%count%' => 1], 'time', $locale); } + $time = $this->convert( $seconds ); return $this->translator->trans( $format[1], - ['%count%' => floor($seconds / $format[2])], + ['%count%' => $time], 'time', $locale ); @@ -121,4 +122,18 @@ private static function formatDateTime(int|string|\DateTimeInterface|null $value return new \DateTime($value); } + + private function convert( float $seconds ): string + { + $secs = $seconds % 60; + $hrs = $seconds / 60; + $mins = $hrs % 60; + + $hrs = $hrs / 60; + if ( (int)$hrs ) { + return (int)$hrs . "." . (int)$mins; + } + + return (int)$mins . "." . (int)$secs; + } }