@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
18 lines (17 loc) • 738 B
TypeScript
import { type UnixUnit } from "../../unix/validate/isValidUnixUnit.js";
/**
* Convert a UTC Instant string to a unix epoch value in milliseconds or seconds.
*
* - Uses Temporal.Instant.from to parse.
* - Validates unit ("seconds" | "milliseconds").
* - Returns null for invalid input.
*
* @param value UTC Instant string
* @param unit optional unit, "seconds" or "milliseconds"
* @returns epoch number or null on invalid
*
* @example convertUtcToUnix("2024-02-29T00:00:00Z") // 1709164800000
* @example convertUtcToUnix("2024-02-29T00:00:00Z", "seconds") // 1709164800
* @example convertUtcToUnix("invalid") // null
*/
export declare function convertUtcToUnix(value: string, ...unitInput: [unit?: UnixUnit]): number | null;