import { Property } from './property/Property'; import { CalendarDuration } from './duration'; export declare const ONE_SECOND_MS = 1000; export declare const ONE_MINUTE_MS: number; export declare const ONE_HOUR_MS: number; export declare const ONE_DAY_MS: number; export declare const ONE_WEEK_MS: number; export declare const ONE_MINUTE_SECONDS = 60; export declare const ONE_HOUR_SECONDS: number; export declare const ONE_DAY_SECONDS: number; export declare const ONE_WEEK_SECONDS: number; export interface CalendarDateOrTime { /** * Get the string value of this date. * @returns An iCalendar date or date-time string. */ getValue(): string; /** * Get the date value of this date. For {@link CalendarDate} this is the * time at the start of the day. * @returns The date value of this date. */ getDate(): Date; /** * Check if this date represents a full day, as opposed to a date-time. * @returns `true` if this object is a {@link CalendarDate}. */ isFullDay(): this is CalendarDate; /** * Get a new time offset by a duration. * @param duration The duration to offset the time by. * @returns A new {@link CalendarDateOrTime} of the same type. */ offset(duration: CalendarDuration): CalendarDateOrTime; } /** * Represents a DATE value as defined by RFC5545. * This is a date without a time, representing a whole day. */ export declare class CalendarDate implements CalendarDateOrTime { private date; constructor(date: Date | string | CalendarDateOrTime); getValue(): string; getDate(): Date; isFullDay(): this is CalendarDate; /** * Get a new date offset by a duration. * @param duration The duration to offset the date by. * @returns A new {@link CalendarDate} offset by the duration. */ offset(duration: CalendarDuration): CalendarDate; [Symbol.toPrimitive](hint: string): number | string | null; } export declare class CalendarDateTime implements CalendarDateOrTime { private date; private absolute; constructor(date: Date | string | CalendarDateOrTime, absolute?: boolean); getValue(): string; getDate(): Date; isFullDay(): this is CalendarDate; /** * Check if this datetime is absolute (in UTC). * @returns If the datetime is absolute. */ isAbsolute(): boolean; /** * Get a new time offset by a duration. * @param duration The duration to offset the time by. * @returns A new {@link CalendarDateTime} offset by the duration. */ offset(duration: CalendarDuration): CalendarDateTime; [Symbol.toPrimitive](hint: string): number | string | null; } /** * Check if an object is a JavaScript `Date`. * @param maybeDate The object to check. * @returns `true` if the object is a `Date`, `false` otherwise. */ export declare function isDateObject(maybeDate: unknown): maybeDate is Date; /** * Check if an object is a `CalendarDateOrTime`. * @param maybeDate The object to check. * @returns `true` if the object is a `CalendarDateOrTime`, `false` otherwise. */ export declare function isCalendarDateOrTime(maybeDate: unknown): maybeDate is CalendarDateOrTime; /** * Pad a number with leading zeros. * @param num The number to pad with zeros. * @param length How many digits the resulting string should have. * @returns The padded string. * @throws If the digits of `num` is greater than `length`. * @throws If `num` is NaN, a decimal or negative. * @throws If `length` is not NaN, a decimal or less than 1. */ export declare function padZeros(num: number, length: number): string; /** * Pad zeros for the year component of a date string. * @param year The year, should be positive. * @returns The 4-digit padded year. */ export declare function padYear(year: number): string; /** * Pad zeros for the month component of a date string. * @param month The month, should be between 1 and 12. * @returns The 2-digit padded month. */ export declare function padMonth(month: number): string; /** * Pad zeros for the day component of a date string. * @param day The day, should be between 1 and 31. * @returns The 2-digit padded day. */ export declare function padDay(day: number): string; /** * Pad zeros for the hours component of a time string. * @param hours The hours, should be between 0 and 23. * @returns The 2-digit padded hours. */ export declare function padHours(hours: number): string; /** * Pad zeros for the minutes component of a time string. * @param minutes The minutes, should be between 0 and 59. * @returns The 2-digit padded minutes. */ export declare function padMinutes(minutes: number): string; /** * Pad zeros for the seconds component of a time string. * @param seconds The seconds, should be between 0 and 59. * @returns The 2-digit padded seconds. */ export declare function padSeconds(seconds: number): string; /** * Parse a date property into a {@link CalendarDateOrTime}. * @param dateProperty The property to parse. * @returns The parsed date as a {@link CalendarDateOrTime}. * @throws If the value is invalid for the value type. * @throws If the value type is not `DATE-TIME` or `DATE`. */ export declare function parseDateProperty(dateProperty: Property): CalendarDateOrTime; /** * Format a date as an iCalendar compatible time string. The day of the date is * ignored. * @param date The date to convert to a time string. * @returns The time of the date formatted according to the iCalendar specification. * @throws If the date is invalid. */ export declare function toTimeString(date: Date): string; /** * Format a date as an iCalendar compatible date string. * @param date The date to convert to a date string. * @returns A date string formatted according to the iCalendar specification. * @throws If the date is invalid. */ export declare function toDateString(date: Date): string; /** * Format a date as an iCalendar compatible date-time string. * @param date The date to convert to a date-time string. * @returns A date-time string formatted according to the iCalendar specification. * @throws If the date is invalid. */ export declare function toDateTimeString(date: Date): string; /** * Format a date as an iCalendar compatible date-time string. Offsets the date * to UTC using `timeZoneOffset`. * @param date The date in local time to convert to UTC and a date-time string. * @param timeZoneOffset The timezone offset in minutes. * @returns A UTC date-time string formatted according to the iCalendar specification. * @throws If the date is invalid. * @throws If the offset is invalid. * @example * // The timezone offset for CET (Central European Time) * const timeZoneOffsetCET = -60 // +01:00 * const date = new Date('2025-08-07T12:00:00') // The time in CET * // Returns "20250807T110000Z" * const utcDate = toDateTimeStringUTC(date, timeZoneOffsetCET) */ export declare function toDateTimeStringUTC(date: Date, timeZoneOffset: number): string; /** * Parse a date-time string to a `Date`. * @param dateTime A date-time string formatted according to the iCalendar specification. * @returns The parsed date-time. * @throws If the date is invalid. */ export declare function parseDateTimeString(dateTime: string): Date; /** * Parse a date string to a `Date`. * @param date A date-time string formatted according to the iCalendar specification. * @returns The parsed date. * @throws If the date is invalid. */ export declare function parseDateString(date: string): Date; /** * Convert `Date` objects to a {@link CalendarDateOrTime} object or return as * is if `date` is already a {@link CalendarDateOrTime}. * @param date The date object to convert. * @param fullDay If `true`, a `Date` object is converted to {@link CalendarDate}, otherwise `Date` is converted to {@link CalendarDateTime}. * @returns A {@link CalendarDateOrTime} as described above. */ export declare function convertDate(date: Date | T, fullDay?: false): T | CalendarDateTime; export declare function convertDate(date: Date | T, fullDay: true): T | CalendarDate; //# sourceMappingURL=date.d.ts.map