Sha256: 1c26365347eaa0fc8a0e4a2f60f4b01448c76264265cab8910e0eb886fe55514
Contents?: true
Size: 769 Bytes
Versions: 76
Compression:
Stored size: 769 Bytes
Contents
import { translate as __, documentLocale } from 'foremanReact/common/I18n'; import { isoCompatibleDate } from 'foremanReact/common/helpers'; import humanizeDuration from 'humanize-duration'; export const durationInWords = ( start, finish, selectedLocale = documentLocale() ) => { if (!start) return __('N/A'); start = new Date(isoCompatibleDate(start)).getTime(); finish = new Date(isoCompatibleDate(finish)).getTime(); return { text: humanizeDuration(new Date(finish - start).getTime(), { largest: 1, language: selectedLocale, fallbacks: ['en'], }), tooltip: `${numberWithDelimiter((finish - start) / 1000)} ${__('seconds')}`, }; }; const numberWithDelimiter = x => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
Version data entries
76 entries across 76 versions & 1 rubygems