date-vir
Version:
Easy and explicit dates and times.
110 lines (109 loc) • 2.99 kB
TypeScript
import { TimeKey } from '../full-date/full-date-parts.js';
import { FullDate } from '../full-date/full-date-shape.js';
import { Timezone } from '../timezone/timezones.js';
/**
* A {@link FullDate} instance that has the lowest, valid, non-negative, value for each property.
*
* @category Constants
*/
export declare const zeroDate: {
readonly year: 0;
readonly month: 1;
readonly day: 1;
readonly hour: 0;
readonly minute: 0;
readonly second: 0;
readonly millisecond: 0;
};
/**
* A {@link FullDate} instance that has the lowest, valid, non-negative, value for each property.
* Alias for {@link zeroDate}.
*
* @category Constants
*/
export declare const emptyDate: {
readonly year: 0;
readonly month: 1;
readonly day: 1;
readonly hour: 0;
readonly minute: 0;
readonly second: 0;
readonly millisecond: 0;
};
/**
* An object that contains the time parts of {@link FullDate} all set to `0`.
*
* @category Constants
*/
export declare const zeroTime: Pick<{
year: 0;
month: 1;
day: 1;
hour: 0;
minute: 0;
second: 0;
millisecond: 0;
}, TimeKey>;
/**
* Clear the time parts of a {@link FullDate}, setting them all to `0`.
*
* @category Clear
* @example
*
* ```ts
* import {clearTime, type FullDate} from 'date-vir';
*
* const exampleDate: Readonly<FullDate> = {
* year: 2024,
* month: 1,
* day: 5,
* hour: 1,
* minute: 1,
* second: 1,
* millisecond: 1,
* timezone: 'UTC',
* };
*
* clearTime(exampleDate);
* // `{year: 2024, month: 1, day: 5, hour: 0, minute: 0, second: 0, millisecond: 0, timezone: 'UTC'}`
* ```
*/
export declare function clearTime<const SpecificTimezone extends Timezone>(inputFullDate: Readonly<FullDate<SpecificTimezone>>): FullDate<SpecificTimezone>;
/**
* Clear all the selected parts of {@link FullDate} by setting them each to their lowest, valid
* value. See {@link zeroDate} for the lowest valid values for each property.
*
* @category Clear
* @example
*
* ```ts
* import {clearTime, type FullDate} from 'date-vir';
*
* const exampleDate: Readonly<FullDate> = {
* year: 2024,
* month: 1,
* day: 5,
* hour: 1,
* minute: 1,
* second: 1,
* millisecond: 1,
* timezone: 'UTC',
* };
*
* clearParts(exampleDate, [
* 'year',
* 'day',
* ]);
* // `{year: 0, month: 1, day: 1, hour: 1, minute: 1, second: 1, millisecond: 1, timezone: 'UTC'}`
* ```
*/
export declare function clearParts<const SpecificTimezone extends Timezone>(inputFullDate: Readonly<FullDate<SpecificTimezone>>, parts: ReadonlyArray<Exclude<keyof FullDate, 'timezone'>>): {
year: number;
month: import("@date-vir/duration").MonthNumber;
day: import("@date-vir/duration").DayOfMonth;
hour: import("@date-vir/duration").Hour;
minute: import("@date-vir/duration").Minute;
millisecond: number;
second: import("@date-vir/duration").Second;
timezone: SpecificTimezone;
};