Skip to content

isValidEdifactDtmFormat

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
isValidEdifactDtmFormat(format: unknown): format is EdifactDtmFormat

Return true when format is a UN/EDIFACT data element 2379 format code that the EDIFACT functions read and write.

  • The 11 supported codes are 102 (a date); 401, 402 (a time); 203, 204 (a date and time with no offset); 205, 208, 303, 304 (a date and time with an offset); 718 (a period of dates) and 719 (a period of date-times). classifyEdifactDtmFormat names the kind of a code, and each kind has its own parser, formatter and validator.
  • A code with a two-digit year returns false: 101, 201, 202, 206, 207, 301, 302, 713 and 717. UN/EDIFACT does not say which century YY belongs to; read such a value with parseDateWithPattern or parseDateTimeWithPattern, a yy pattern and its yearWindow option.
  • 209 and 404 (a time with an offset and no date) and 406 (an offset alone) return false: none names a date, a time, a date-time or an instant.
  • Every other 2379 code returns false: the day-first and month-first dates 2–5, 10 (CCYYMMDDTHHMM), 103, the ordinal date 105, 210, 307, 308, the time spans 501–503, 711, the partial values, the weekday period 720 and the quantities (801 and up).
  • Matching is exact: " 203", "0203" and the number 203 are not codes.
  • Accepts any input type and returns false for non-string values.
  • A parser returns its sentinel for a code it does not read, the same sentinel it returns for a value that does not fit its code. Check the code here to tell an unsupported format apart from bad data.
ParameterTypeDescription
formatunknowncandidate value of any type

boolean indicating validity

The UN/EDIFACT data element 2379 (Date or time or period format code) values GMT reads and writes: 11 codes, each in the union of the one kind of value it states. Twelve directories were read: UNECE’s own D.21B and D.22B pages, archived, and mirrors of D.93A, D.96A, D.01B, D.01C, D.03A, D.03B, D.04B, D.11B, D.12A and D.13B. No mask of a code GMT reads changed across them.

import type { EdifactDtmFormat } from "@northguild/gmt";
"102" | "718" | EdifactDateTimeFormat | "719" | EdifactOffsetDateTimeFormat | EdifactTimeFormat
import { isValidEdifactDtmFormat } from "@northguild/gmt/intermodal/validate";
isValidEdifactDtmFormat("203") // true
output 

intermodal/validate/isValidEdifactDtmFormat.ts