formatX12DateTimeRange
Signature
Section titled “Signature”formatX12DateTimeRange(start: string, end: string, format: X12DateTimeRangeFormat): stringWrite two ISO 8601 local date-times as an X12 Date Time Period range (data element 1251) in a date-time range format qualifier (data element 1250). The inverse of parseX12DateTimeRange.
-
Codes are release 005010, read from Stedi’s X12-licensed dictionary; the X12 text itself was not reached. ### Format codes
Code Mask The dictionary’s definition RDTCCYYMMDDHHMM-CCYYMMDDHHMM“Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM” DTSCCYYMMDDHHMMSS-CCYYMMDDHHMMSS“Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS” -
startandendare local date-times, asisValidDateTimeaccepts them: the two membersparseX12DateTimeRangereturns. A date, an instant ending inZand a date-time with an offset return"": no 1250 code carries an offset. -
The range is written with the one hyphen X12 transmits.
-
Precision is cut to the mask, never rounded: a fraction of a second is always dropped from both ends, and
RDTdrops the seconds too. -
An end before its start returns
"": a reversed range names no span of time. The ends are compared as given, before either is cut to the mask. An end equal to its start is written. -
A year outside 0000–9999 in either end returns
"". -
Returns
""for any other code, a code of another kind included, and for a non-string argument.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO 8601 local date-time the range starts at (e.g. “2024-06-15T14:30:00”) |
end | string | ISO 8601 local date-time the range ends at (e.g. “2024-06-20T16:00:00”) |
format | X12DateTimeRangeFormat | X12 data element 1250 format qualifier |
Returns
Section titled “Returns”the data element 1251 value, or "" on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatX12DateTimeRange } from "@northguild/gmt/intermodal/format";
formatX12DateTimeRange("2024-06-15T14:30:00", "2024-06-20T16:00:00", "RDT") // "202406151430-202406201600"