@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
31 lines (30 loc) • 1.13 kB
TypeScript
/**
* Return the ISO week number for a given ISO 8601 date string.
*
* - Uses Temporal.PlainDate.weekOfYear (Monday-based ISO weeks).
* - Returns null for invalid input.
*
* @param value ISO 8601 date string
* @returns Week number (1-53) or null on invalid input
*
* @example weekOfYearForDate("2024-01-01") // 1
* @example weekOfYearForDate("2024-01-07") // 1
* @example weekOfYearForDate("2024-01-08") // 2
* @example weekOfYearForDate("2024-12-31") // 1
* @example weekOfYearForDate("invalid") // null
*/
export declare function weekOfYearForDate(value: string): number | null;
/**
* Return the ISO week number for a given ISO 8601 datetime string.
*
* - Uses Temporal.PlainDate.weekOfYear (Monday-based ISO weeks).
* - Returns null for invalid input.
*
* @param value ISO 8601 datetime string
* @returns Week number (1-53) or null on invalid input
*
* @example weekOfYearForDateTime("2024-01-01T12:00:00") // 1
* @example weekOfYearForDateTime("2024-01-08T00:00:00") // 2
* @example weekOfYearForDateTime("invalid") // null
*/
export declare function weekOfYearForDateTime(value: string): number | null;