datezone
Version:
A lightweight and comprehensive date and timeZone utility library for JavaScript.
91 lines • 3.29 kB
TypeScript
import type { TimeZone } from "./timezone.pub.js";
/**
* Extracts the year from a timestamp.
*
* @param ts - The timestamp to extract the year from
* @param tz - Optional timeZone (defaults to local time)
* @returns The year as a number
* @see https://datezone.dev/docs/reference/year#year
*/
export declare function year(ts: number, tz: TimeZone | null): number;
/**
* Checks if leap year.
*
* @param ts - The timestamp to check
* @param tz - Optional timeZone (defaults to local time)
* @returns True if the year is a leap year, false otherwise
* @see https://datezone.dev/docs/reference/year#isleapyear
*/
export declare function isLeapYear(ts: number, tz: TimeZone | null): boolean;
/**
* Checks if leap year base.
*
* @param year - The year to check
* @returns True if the year is a leap year, false otherwise
* @see https://datezone.dev/docs/reference/year#isleapyearbase
*/
export declare function isLeapYearBase(year: number): boolean;
/**
* Start of year.
*
* @param ts - The timestamp to get the start of year for
* @param tz - Optional timeZone (defaults to local time)
* @returns Timestamp for the start of the year (January 1st, 00:00:00.000)
* @see https://datezone.dev/docs/reference/year#startofyear
*/
export declare function startOfYear(ts: number, tz: TimeZone | null): number;
/**
* End of year.
*
* @param ts - The timestamp to get the end of year for
* @param tz - Optional timeZone (defaults to local time)
* @returns Timestamp for the end of the year (December 31st, 23:59:59.999)
* @see https://datezone.dev/docs/reference/year#endofyear
*/
export declare function endOfYear(ts: number, tz: TimeZone | null): number;
/**
* Add years.
*
* @param ts - The timestamp to add years to
* @param amount - Number of years to add (can be negative)
* @param tz - Optional timeZone (defaults to local time)
* @returns New timestamp with years added
* @see https://datezone.dev/docs/reference/year#addyears
*/
export declare function addYears(ts: number, amount: number, tz: TimeZone | null): number;
/**
* Subtract years.
*
* @param ts - The timestamp to subtract years from
* @param amount - Number of years to subtract
* @param tz - Optional timeZone (defaults to local time)
* @returns New timestamp with years subtracted
* @see https://datezone.dev/docs/reference/year#subyears
*/
export declare function subYears(ts: number, amount: number, tz: TimeZone | null): number;
/**
* Days in year.
*
* @param ts - The timestamp to check
* @param tz - Optional timeZone (defaults to local time)
* @returns 366 for leap years, 365 for non-leap years
* @see https://datezone.dev/docs/reference/year#daysinyear
*/
export declare function daysInYear(ts: number, tz: TimeZone | null): number;
/**
* Days in year base.
*
* @param year - The year to check
* @returns 366 for leap years, 365 for non-leap years
* @see https://datezone.dev/docs/reference/year#daysinyearbase
*/
export declare function daysInYearBase(year: number): number;
/**
* Extracts the quarter from a timestamp.
*
* @param month - The month number (1-12)
* @returns The quarter number (1-4)
* @see https://datezone.dev/docs/reference/year#quarter
*/
export declare function quarter(month: number): number;
//# sourceMappingURL=year.pub.d.ts.map