datezone
Version:
A lightweight and comprehensive date and timeZone utility library for JavaScript.
61 lines • 2.04 kB
TypeScript
import type { TimeZone } from "./timezone.pub.js";
/**
* To12 hour.
*
* @param hour - The hour in 24-hour format (0-23)
* @returns The hour in 12-hour format (1-12)
* @see https://datezone.dev/docs/reference/hour#to12hour
*/
export declare function to12Hour(hour: number): number;
/**
* To24 hour.
*
* @param hour - The hour value to normalize
* @returns The hour in 24-hour format (0-23)
* @see https://datezone.dev/docs/reference/hour#to24hour
*/
export declare function to24Hour(hour: number): number;
/**
* Extracts the hour from a timestamp.
*
* @param ts - The timestamp in milliseconds
* @param timeZone - Optional IANA timeZone identifier (e.g., 'America/New_York')
* @returns The hour value in ISO 8601 24-hour format (0-23)
* @see https://datezone.dev/docs/reference/hour#hour
*/
export declare function hour(ts: number, timeZone: TimeZone | null): number;
/**
* Add hours.
*
* @param ts - The timestamp in milliseconds
* @param hours - The number of hours to add (can be negative)
* @returns A new timestamp with the hours added
* @see https://datezone.dev/docs/reference/hour#addhours
*/
export declare function addHours(ts: number, hours: number): number;
/**
* Subtract hours.
*
* @param ts - The timestamp in milliseconds
* @param hours - The number of hours to subtract
* @returns A new timestamp with the hours subtracted
* @see https://datezone.dev/docs/reference/hour#subhours
*/
export declare function subHours(ts: number, hours: number): number;
/**
* Start of hour.
*
* @param ts - The timestamp in milliseconds
* @returns A new timestamp representing the start of the hour
* @see https://datezone.dev/docs/reference/hour#startofhour
*/
export declare function startOfHour(ts: number): number;
/**
* End of hour.
*
* @param ts - The timestamp in milliseconds
* @returns A new timestamp representing the end of the hour
* @see https://datezone.dev/docs/reference/hour#endofhour
*/
export declare function endOfHour(ts: number): number;
//# sourceMappingURL=hour.pub.d.ts.map