UNPKG

@instawork/design-system

Version:

The design system for Instawork's web apps

48 lines (47 loc) 2.21 kB
import { DateTime, Duration } from 'luxon'; export declare const DATE_FORMAT_PYTHON_NAIVE = "yyyy-LL-dd HH:mm:ss"; export declare const DATE_FORMAT_PYTHON_AWARE: string; export declare const DATE_FORMATS: string[]; export declare const TIME_ZONE_SUPPORT: boolean; export interface TryParseDateTimeOptions { timeZone?: string; baseDate?: string | DateTime; } export interface TryParseTimeOptions { timeZone?: string; baseDate: DateTime; } export declare class DateUtil { static readonly TIME_ZONE_SUPPORT: boolean; static readonly DATE_FORMAT_PYTHON_NAIVE = "yyyy-LL-dd HH:mm:ss"; static readonly DATE_FORMAT_PYTHON_AWARE: string; static readonly DATE_FORMATS: string[]; /** * Attempts to construct a full date time value from a full datetime or partial time value. * * @param input * @param timeZone - converts the resulting DateTime to the specified timeZone * @param baseDate - used as the date when the input includes only the time */ static tryParseDateTime(input: string, { timeZone, baseDate }?: TryParseDateTimeOptions): DateTime; /** * Attempt to construct a DateTime using the input as time, and the date from the "originalValue". */ static tryParseTime(input: string, { timeZone, baseDate }: TryParseTimeOptions): DateTime; /** * Formats the hours with a minimum of 1 decimal places, and a maximum of 2 decimal places. */ static formatHours(hours: number): string; /** * Formats the hours with a minimum of 1 decimal places, and a maximum of 2 decimal places. * @param diff * @param abbreviatedLabels - Use "hrs" and "mins" instead of "hours" and "minutes"; defaults to `true` * @param prefixPositiveValues - Prefix values greater than zero with a "+" sign; defaults to `true` */ static formatHoursDiff(diff: Duration, abbreviatedLabels?: boolean, prefixPositiveValues?: boolean): string; /** * Formats an informational message that the hours total includes time from changing to or from DST. */ static formatDstChange(offsetChange: number): string; static invalidate(value: DateTime, reason: string, explanation: string): DateTime; }