Index: trunk/phase3/languages/Language.php |
— | — | @@ -1919,7 +1919,7 @@ |
1920 | 1920 | * |
1921 | 1921 | * @return string |
1922 | 1922 | */ |
1923 | | - public function formatDuration( $seconds, array $chosenIntervals = array( 'millennia', 'centuries', 'decades', 'years', 'days', 'hours', 'minutes', 'seconds' ) ) { |
| 1923 | + public function formatDuration( $seconds, array $chosenIntervals = array() ) { |
1924 | 1924 | $intervals = array( |
1925 | 1925 | 'millennia' => 1000 * 31557600, |
1926 | 1926 | 'centuries' => 100 * 31557600, |
— | — | @@ -1932,16 +1932,20 @@ |
1933 | 1933 | 'seconds' => 1, |
1934 | 1934 | ); |
1935 | 1935 | |
1936 | | - if ( !empty( $chosenIntervals ) ) { |
1937 | | - $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) ); |
| 1936 | + if ( empty( $chosenIntervals ) ) { |
| 1937 | + $chosenIntervals = array( 'millennia', 'centuries', 'decades', 'years', 'days', 'hours', 'minutes', 'seconds' ); |
1938 | 1938 | } |
1939 | 1939 | |
| 1940 | + $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) ); |
| 1941 | + $sortedNames = array_keys( $intervals ); |
| 1942 | + $smallestInterval = array_pop( $sortedNames ); |
| 1943 | + |
1940 | 1944 | $segments = array(); |
1941 | 1945 | |
1942 | 1946 | foreach ( $intervals as $name => $length ) { |
1943 | 1947 | $value = floor( $seconds / $length ); |
1944 | 1948 | |
1945 | | - if ( $value > 0 || ( $name == 'seconds' && empty( $segments ) ) ) { |
| 1949 | + if ( $value > 0 || ( $name == $smallestInterval && empty( $segments ) ) ) { |
1946 | 1950 | $seconds -= $value * $length; |
1947 | 1951 | $message = new Message( 'duration-' . $name, array( $value ) ); |
1948 | 1952 | $segments[] = $message->inLanguage( $this )->escaped(); |