datezone
Version:
A lightweight and comprehensive date and timeZone utility library for JavaScript.
196 lines • 7.6 kB
TypeScript
import type { TimeZone } from "./timezone.pub.js";
/**
* Extracts the month from a timestamp.
*
* @param ts - The timestamp to get the month for
* @param timeZone - Optional timeZone (defaults to local time)
* @returns The month of the year (1-12)
* @see https://datezone.dev/docs/reference/month#month
*/
export declare function month(ts: number, timeZone: TimeZone | null): number;
/**
* Start of month.
*
* @param ts - The timestamp to get the start of month for
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the start of the month
* @see https://datezone.dev/docs/reference/month#startofmonth
*/
export declare function startOfMonth(ts: number, timeZone: TimeZone | null): number;
/**
* Start of month base.
*
* @param year - The year
* @param month - The month (1-12)
* @param timeZone - The timeZone
* @returns Timestamp for the start of the month
* @see https://datezone.dev/docs/reference/month#startofmonthbase
*/
export declare function startOfMonthBase(year: number, month: number, timeZone: TimeZone): number;
/**
* End of month.
*
* @param ts - The timestamp to get the end of month for
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the end of the month (last millisecond)
* @see https://datezone.dev/docs/reference/month#endofmonth
*/
export declare function endOfMonth(ts: number, timeZone: TimeZone | null): number;
/**
* End of month base.
*
* @param year - The year
* @param month - The month (1-12)
* @param timeZone - The timeZone
* @returns Timestamp for the end of the month (last millisecond)
* @see https://datezone.dev/docs/reference/month#endofmonthbase
*/
export declare function endOfMonthBase(year: number, month: number, timeZone: TimeZone): number;
/**
* Add months.
*
* @param ts - The timestamp to add months to
* @param months - Number of months to add (can be negative)
* @param timeZone - Optional timeZone (defaults to local time)
* @returns New timestamp with months added
* @see https://datezone.dev/docs/reference/month#addmonths
*/
export declare function addMonths(ts: number, months: number, timeZone: TimeZone | null): number;
/**
* Add months base.
*
* @param year - The year
* @param month - The month (1-12)
* @param day - The day
* @param hour - The hour
* @param minute - The minute
* @param second - The second
* @param millisecond - The millisecond
* @param monthsToAdd - Number of months to add (can be negative)
* @param timeZone - The timeZone
* @returns New timestamp with months added
* @see https://datezone.dev/docs/reference/month#addmonthsbase
*/
export declare function addMonthsBase(year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number, monthsToAdd: number, timeZone: TimeZone): number;
/**
* Subtract months.
*
* @param ts - The timestamp to subtract months from
* @param months - Number of months to subtract
* @param timeZone - Optional timeZone (defaults to local time)
* @returns New timestamp with months subtracted
* @see https://datezone.dev/docs/reference/month#submonths
*/
export declare function subMonths(ts: number, months: number, timeZone: TimeZone | null): number;
/**
* Start of nth month.
*
* @param ts - The reference timestamp
* @param n - Number of months to offset (0 = current month, 1 = next month, -1 = previous month)
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the start of the nth month
* @see https://datezone.dev/docs/reference/month#startofnthmonth
*/
export declare function startOfNthMonth(ts: number, n: number, timeZone: TimeZone | null): number;
/**
* End of nth month.
*
* @param ts - The reference timestamp
* @param n - Number of months to offset (0 = current month, 1 = next month, -1 = previous month)
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the end of the nth month (last millisecond)
* @see https://datezone.dev/docs/reference/month#endofnthmonth
*/
export declare function endOfNthMonth(ts: number, n: number, timeZone: TimeZone | null): number;
/**
* Start of next month.
*
* @param ts - The reference timestamp
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the start of the next month
* @see https://datezone.dev/docs/reference/month#startofnextmonth
*/
export declare function startOfNextMonth(ts: number, timeZone: TimeZone | null): number;
/**
* End of next month.
*
* @param ts - The reference timestamp
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the end of the next month (last millisecond)
* @see https://datezone.dev/docs/reference/month#endofnextmonth
*/
export declare function endOfNextMonth(ts: number, timeZone: TimeZone | null): number;
/**
* Start of prev month.
*
* @param ts - The reference timestamp
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the start of the previous month
* @see https://datezone.dev/docs/reference/month#startofprevmonth
*/
export declare function startOfPrevMonth(ts: number, timeZone: TimeZone | null): number;
/**
* End of prev month.
*
* @param ts - The reference timestamp
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Timestamp for the end of the previous month (last millisecond)
* @see https://datezone.dev/docs/reference/month#endofprevmonth
*/
export declare function endOfPrevMonth(ts: number, timeZone: TimeZone | null): number;
/**
* Days in month.
*
* @param ts - The timestamp
* @param timeZone - Optional timeZone (defaults to local time)
* @returns Number of days in the month
* @see https://datezone.dev/docs/reference/month#daysinmonth
*/
export declare function daysInMonth(ts: number, timeZone: TimeZone | null): number;
/**
* Days in month base.
*
* @param year - The year
* @param month - The month (1-12)
* @returns Number of days in the month
* @see https://datezone.dev/docs/reference/month#daysinmonthbase
*/
export declare function daysInMonthBase(year: number, month: number): number;
/**
* Calculate year month.
*
* @param year - The starting year
* @param month - The starting month (1-12)
* @param monthsToAdd - Number of months to add (can be negative)
* @returns Tuple with the new year and month [year, month]
* @see https://datezone.dev/docs/reference/month#calculateyearmonth
*/
export declare function calculateYearMonth(year: number, month: number, monthsToAdd: number): [number, number];
/**
* Get month name.
*
* @param locale - The locale string (e.g., 'en-US', 'fr-FR')
* @param type - The format type: 'long' (January), 'short' (Jan), or 'narrow' (J)
* @param month - The month number (1-12)
* @returns The localized month name
* @see https://datezone.dev/docs/reference/month#getmonthname
*/
export declare function getMonthName(locale: string, type: "long" | "short" | "narrow", month: number): string;
/**
* Get quarter.
*
* @param ts - The timestamp
* @param timeZone - Optional timeZone (defaults to local time)
* @returns The quarter number (1-4)
* @see https://datezone.dev/docs/reference/month#getquarter
*/
export declare function getQuarter(ts: number, timeZone: TimeZone | null): number;
/**
* Get quarter base.
*
* @param month - The month (1-12)
* @returns The quarter number (1-4)
* @see https://datezone.dev/docs/reference/month#getquarterbase
*/
export declare function getQuarterBase(month: number): number;
//# sourceMappingURL=month.pub.d.ts.map