* Small usage cleanups * Adjustments for nodes * Hopefully sort out Badge/Icon alignment * ui--Icon pointers
19 lines
920 B
TypeScript
19 lines
920 B
TypeScript
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import { TFunction } from 'i18next';
|
|
import { Time } from '@polkadot/util/types';
|
|
|
|
export default function timeToString (t: TFunction, { days, hours, minutes, seconds }: Time): string {
|
|
return [
|
|
days ? (days > 1) ? t<string>('{{days}} days', { replace: { days } }) : t<string>('1 day') : null,
|
|
hours ? (hours > 1) ? t<string>('{{hours}} hrs', { replace: { hours } }) : t<string>('1 hr') : null,
|
|
minutes ? (minutes > 1) ? t<string>('{{minutes}} mins', { replace: { minutes } }) : t<string>('1 min') : null,
|
|
seconds ? (seconds > 1) ? t<string>('{{seconds}} s', { replace: { seconds } }) : t<string>('1 s') : null
|
|
]
|
|
.filter((value): value is string => !!value)
|
|
.slice(0, 2)
|
|
.join(' ');
|
|
}
|