UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

50 lines (49 loc) 2.04 kB
import { DateTime as LuxonDateTime, DateTimeUnit as LuxonDateTimeUnit, DurationUnit as LuxonDurationUnit } from 'luxon'; import { Value } from '../types/Value'; import { Optional } from '../types/Types'; import { JsonValue } from '../types/Json'; export type DateTimeUnit = LuxonDateTimeUnit; export type DurationUnit = LuxonDurationUnit; export type Duration = Partial<Record<DurationUnit, number>>; export type DiffOptions = { rounding: 'floor' | 'ceil' | 'round'; }; export type DatetimeInput = string | number | Date | DateTime | null; export declare class DateTime extends Value<Optional<string>> { protected readonly luxon: LuxonDateTime; constructor(value?: DatetimeInput); constructor(value?: string, format?: string); static get now(): DateTime; get isValid(): boolean; get fromNow(): string; get inAmsterdam(): DateTime; get inNewYork(): DateTime; get inLondon(): DateTime; get inWarsaw(): DateTime; protected get utc(): LuxonDateTime; from(locale?: string): string; from(date?: DateTime, locale?: string): string; isAfter(dt: DateTime): boolean; isBefore(dt: DateTime): boolean; equals(dt: DateTime): boolean; add(n: number, unit?: DurationUnit): DateTime; add(duration: Duration): DateTime; subtract(n: number, unit?: DurationUnit): DateTime; subtract(duration: Duration): DateTime; diff(other: DateTime, unit?: DateTimeUnit, opts?: DiffOptions): number; startOf(unit?: DateTimeUnit): DateTime; endOf(unit?: DateTimeUnit): DateTime; isWeekend(): boolean; withZone(zone: string): DateTime; toString(): string; toJSON(): JsonValue; toFormat(format: string): string; toLocale(locale?: string, format?: string): string; toFull(locale?: string): string; toDate(): Optional<Date>; toEpoch(): number; ago(end?: DateTime): string; withClock(clock: DateTime): DateTime; } export declare const isDateTime: (dt?: unknown) => dt is DateTime; export declare const dt: (dt?: DatetimeInput) => DateTime;