X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=languages%2FLanguage.php;h=2262fa775e97cf70622fd900adcc766d9fc2459d;hp=3a12439e6e97b745122a34f869f0dee7df6944f7;hb=9f5c319b091fc84796c1e841699cc70c7566bef7;hpb=81c91fd493fd52926b454826d621c60b7818503f diff --git a/languages/Language.php b/languages/Language.php index 3a12439e6e..2262fa775e 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -4658,6 +4658,7 @@ class Language { * * @param int|float $seconds * @param array $format An optional argument that formats the returned string in different ways: + * If $format['avoid'] === 'avoidhours': don't show hours, just show days * If $format['avoid'] === 'avoidseconds': don't show seconds if $seconds >= 1 hour, * If $format['avoid'] === 'avoidminutes': don't show seconds/minutes if $seconds > 48 hours, * If $format['noabbrevs'] is true: use 'seconds' and friends instead of 'seconds-abbrev' @@ -4716,12 +4717,19 @@ class Language { $s = $hoursMsg->params( $this->formatNum( $hours ) )->text(); $s .= ' '; $s .= $minutesMsg->params( $this->formatNum( $minutes ) )->text(); - if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes' ] ) ) { + if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes', 'avoidhours' ] ) ) { $s .= ' ' . $secondsMsg->params( $this->formatNum( $secondsPart ) )->text(); } } else { $days = floor( $seconds / 86400 ); - if ( $format['avoid'] === 'avoidminutes' ) { + if ( $format['avoid'] === 'avoidhours' ) { + $hours = round( ( $seconds - $days * 86400 ) / 3600 ); + if ( $hours == 24 ) { + $hours = 0; + $days++; + } + $s = $daysMsg->params( $this->formatNum( $days ) )->text(); + } elseif ( $format['avoid'] === 'avoidminutes' ) { $hours = round( ( $seconds - $days * 86400 ) / 3600 ); if ( $hours == 24 ) { $hours = 0;