@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
28 lines • 1.48 kB
TypeScript
/** The first year SWIFT accepts in a value date (Standards MT General Information, 2025, §6.3.1). */
export declare const SWIFT_VALUE_DATE_FIRST_YEAR = 2001;
/** The last year SWIFT accepts in a value date; any other year is error T50 (same, §6.3.6). */
export declare const SWIFT_VALUE_DATE_LAST_YEAR = 2060;
/** The fields of a `YYMMDD` value, as numbers: two-digit year 0–99, month 0–99, day 0–99. */
export interface SwiftDateFields {
yy: number;
month: number;
day: number;
}
/** Read the fields of a `YYMMDD` value, or null when the shape does not match. */
export declare function readSwiftDateFields(value: string): SwiftDateFields | null;
/**
* The year SWIFT's value-date rule gives a two-digit `yy`, or null for error T50.
* §6.3.6: a `YY` from 01 through 60 is allowed, and §6.3.1 reads it as 20`YY` (2001 to 2060);
* any other `YY`, `00` and `61`–`99` included, is error T50.
*/
export declare function swiftValueDateYear(yy: number): number | null;
/** Write `YYMMDD` from a year 2001–2060, a month 1–12 and a day 1–31. The caller passes valid values. */
export declare function writeSwiftDate(year: number, month: number, day: number): string;
/**
* The core of `parseSwiftDate` and `isValidSwiftDate`: the ISO date a SWIFT `YYMMDD` value date
* names, or `""`. Never throws.
*
* @example readSwiftDate("240315") // "2024-03-15"
* @example readSwiftDate("240230") // ""
*/
export declare function readSwiftDate(value: string): string;