/** * Convert Time Duration to User Friendly and Readable Format * * @param {Number} milliseconds - duration in milliseconds to convert * @param {Object} [options] - other humanize options, like `largest` to trim down units * @param {Boolean} [shorten] - whether to shorten words, like `seconds` to `s` * @returns {String} - formatted time */ export function formatDuration(milliseconds: number, { shorten, round, ...props }?: Object | undefined): string; export namespace formatDuration { const shortEnglish: any; } /** * Convert time to human readable date and time * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @param {String} [format] - to render date time as * @returns {String} - date time in given format */ export function formatTime(time: string | number | Date, format?: string | undefined): string; /** * Convert 24hr and minute format string (HH:mm) to Milliseconds * * @param {String} hourMinute - to convert * @returns {Number} milliseconds */ export function msFromHourMinute(hourMinute?: string): number; /** * Convert Number to String with leading zero/s at specified character length * @param {Number|String} number - to format * @param {Number} [length] - total character length of output, default is 2 * @returns {String} time - string with leading zero/s if needed */ export function toLeadingZero(number: number | string, length?: number | undefined): string; /** * Convert time to full hour string * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @return {String} - hours and minutes */ export function toHours(time: string | number | Date): string; /** * Convert time to hour and minute string * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @return {String} - hours and minutes */ export function toHourMinutes(time: string | number | Date): string; /** * Convert time to Day and Month string * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @return {String} - Day and Month */ export function toDate(time: string | number | Date): string; /** * Convert time to Day, Month and Year string * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @return {String} - Day Month, Year */ export function toDateYear(time: string | number | Date): string; /** * Convert time toMonth and Year string * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @return {String} - Month and Year */ export function toMonthYear(time: string | number | Date): string; /** * Convert Start and End timestamp range to Human-friendly string * * @param {Number} start - timestamp * @param {Number} end - timestamp * @returns {String} date range - ex. `21 Sep - 17 Oct, 2019` or `13 - 21 Sep, 2019` or `13 Sep, 2019`` */ export function toDateRange(start: number, end: number): string; /** * Convert Date String to Unix Timestamp * @param {String} dayMonthYear - DD.MM.YYYY * @returns {Number|Undefined} timestamp - if given date string is valid, else undefined */ export function timestampFromDate(dayMonthYear: string): number | undefined; /** * Convert List of Dates with Hours and Minutes to list of Unix Timestamp Ranges * * @param {Array<{date: 'dd.mm.yyyy', from: 'hh:mm', to: 'hh:mm'}>} dates - list of dates with hours and minutes * @returns {Array<{from: Number, to: Number}>} times - list of Unix timestamp ranges */ export function toTimeRanges(dates: Array<{ date: 'dd.mm.yyyy'; from: 'hh:mm'; to: 'hh:mm'; }>): Array<{ from: number; to: number; }>; /** * Convert Date with Hours and Minutes to Unix Timestamp Range * * @param {{date: string, from: string, to: string}} dateTime - {date: 'dd.mm.yyyy', from: 'hh:mm', to: 'hh:mm', ...} * @returns {{from?: number, to?: number}} time - Unix timestamp range */ export function toTimeRange({ date, from, to, ...result }: { date: string; from: string; to: string; }): { from?: number; to?: number; }; /** * Convert List of Unix Timestamp Ranges to list of Dates with Hours and Minutes * @param {Array<{from: Number, to: Number}>} times - list of Unix timestamp ranges * @returns {Array<{date: 'dd.mm.yyyy', from: 'hh:mm', to: 'hh:mm'}>} dates - list of dates with hours and minutes */ export function fromTimeRanges(times: Array<{ from: number; to: number; }>): Array<{ date: 'dd.mm.yyyy'; from: 'hh:mm'; to: 'hh:mm'; }>; /** * Compute total milliseconds for given list of time ranges * @param {Array<{from: Number, to: Number}>} times - list of Unix timestamp ranges * @returns {Number} time - milliseconds */ export function totalFromTimeRanges(times: Array<{ from: number; to: number; }>): number; /** * Convert time to Unix timestamp in milliseconds * * @param {String|Number|Date} time - date string, Unix timestamp, Date object, etc. * @param {Number} [fallback] - timestamp to use in case conversion fails * @returns {Number} - timestamp in milliseconds */ export function toTimestamp(time: string | number | Date, fallback?: number | undefined): number; /** * Get a short string indicating time for given date in human-friendly way * @example: * @return: 'Yesterday', '1 day ago', '2 weeks ago', * @param timestamp */ export function timeSince(timestamp: any): string; export { moment }; export class Time { /** * Get Milliseconds Until the Next Full Hour */ static get tillNextHour(): number; /** * Get Milliseconds Until the Next Full 30 Minutes */ static get tillNext30Mins(): number; /** * Get Milliseconds Until the Next Full 15 Minutes */ static get tillNext15Mins(): number; /** * Get Milliseconds Until the Next Full Duration Provided * (duration given must be less than ONE_HOUR) */ static tillNext(duration: any): number; } import moment from "dayjs";