import { LocalDateUnit } from '@xh/hoist/core'; import { Moment, MomentInput } from 'moment'; /** * A Date representation that does not contain time information. Useful for business day or calendar * day data where time and time zone should be explicitly ignored. Client-side equivalent of the * Java `LocalDate` class. * * This class is immutable. All methods for manipulation return a new LocalDate instance. * For efficiency and to enable strict equality checks, instances of this class are memoized: * only a single version of the object will be created and returned for each calendar day, * as long as the caller uses one of the *public factory methods*, which they always should! * * Instances serialize directly to their ISO date string (e.g. '2024-01-15') via built-in * `toString()`, `valueOf()`, and `toJSON()` overrides. This means a LocalDate can be passed * as-is within the params or body of a `FetchService` request (or any `JSON.stringify()` call) * and will serialize as expected - prefer this over calling `toString()` or `format()` yourself. * * Instances also support natural comparison: because they are memoized, `===` tests whether two * references are the same calendar day, while `valueOf()` returning the (lexically sortable) ISO * string means the relational operators `<`, `>`, `<=`, `>=` order instances chronologically. */ export declare class LocalDate { static readonly VALID_UNITS: Set; private static _instances; private readonly _isoString; private readonly _moment; private readonly _date; /** * Get an instance of this class. * This is the standard way to get an instance of this object from serialized server-side data. * * @param s - a valid date in 'YYYY-MM-DD' or 'YYYYMMDD' format. */ static get(s: string): LocalDate; /** * Get an instance of this class. * * Note: Applications should favor using the `get()` factory instead of this method. * `get()` takes an explicit 'YYYYMMDD' or 'YYYY-MM-DD' format and is the safest way to get * a LocalDate. * * @param val - any string, timestamp, or date parsable by moment.js. */ static from(val: MomentInput | LocalDate): LocalDate; /** * LocalDate representing the current day in the browser's local time zone. * See `currentAppDay()` / `currentServerDay()` to resolve "today" in the app or server zone, * which can differ from the browser for users in another region. */ static today(): LocalDate; /** LocalDate representing the current day in the App TimeZone */ static currentAppDay(): LocalDate; /** LocalDate representing the current day in the Server TimeZone */ static currentServerDay(): LocalDate; /** LocalDate representing the next day. */ static tomorrow(): LocalDate; /** LocalDate representing the previous day. */ static yesterday(): LocalDate; /** Is the input value a local Date? */ static isLocalDate(val: any): boolean; get isoString(): string; /** JS `Date` for this day at midnight in the browser's local time zone. Fresh instance per call. */ get date(): Date; /** A mutable moment.js clone - safe to modify without affecting this (immutable) instance. */ get moment(): Moment; /** Epoch millis for this day at midnight in the browser's local time zone. */ get timestamp(): number; /** * Format this date using moment.js format tokens, primarily for display. * Note: to send a LocalDate to the server, pass the instance directly rather than a formatted * string - it serializes to an ISO date on its own (see class-level docs). */ format(...args: any[]): string; dayOfWeek(): string; get isToday(): boolean; get isWeekday(): boolean; get isStartOfMonth(): boolean; get isEndOfMonth(): boolean; get isStartOfQuarter(): boolean; get isEndOfQuarter(): boolean; get isStartOfYear(): boolean; get isEndOfYear(): boolean; toString(): string; toJSON(): string; valueOf(): string; get isLocalDate(): boolean; add(value: number, unit?: LocalDateUnit): LocalDate; subtract(value: number, unit?: LocalDateUnit): LocalDate; addWeekdays(value: number): LocalDate; subtractWeekdays(value: number): LocalDate; startOf(unit: LocalDateUnit): LocalDate; startOfMonth(): LocalDate; startOfQuarter(): LocalDate; startOfYear(): LocalDate; endOf(unit: any): LocalDate; endOfMonth(): LocalDate; endOfQuarter(): LocalDate; endOfYear(): LocalDate; nextDay(): LocalDate; previousDay(): LocalDate; nextWeekday(): LocalDate; previousWeekday(): LocalDate; /** The same date if already a weekday, or the next weekday. */ currentOrNextWeekday(): LocalDate; /** The same date if already a weekday, or the previous weekday. */ currentOrPreviousWeekday(): LocalDate; /** Difference between this date and `other` in the given unit; positive when this is later. */ diff(other: LocalDate, unit?: LocalDateUnit): number; /** @internal - use one of the static factory methods instead. */ private constructor(); private ensureUnitValid; } /** @returns true if the input value is a `LocalDate` instance. */ export declare function isLocalDate(val: any): val is LocalDate;