Skip to content

isValidEdifactOffsetDateTime

  • Container free time, demurrage, billing deadlines, bill of lading dates and EDI timestamps.
isValidEdifactOffsetDateTime(value: string, format: EdifactOffsetDateTimeFormat): boolean

Return true when value is a UN/EDIFACT DTM value (data element 2380) that states a real date and time with an offset from UTC, in a format code that carries one (data element 2379).

  • CodeMaskThe directory’s description
    205CCYYMMDDHHMMZHHMM“Calendar date including time and time zone expressed in hours and minutes.”
    208CCYYMMDDHHMMSSZHHMM“Calendar date including time with seconds, with Time Zone” (D.12A and later)
    303CCYYMMDDHHMMZZZ“See 203 plus Z=Time zone.”
    304CCYYMMDDHHMMSSZZZ“See 204 plus Z=Time zone.”
  • True exactly when parseEdifactOffsetDateTime returns a value for the same arguments: the validator calls the parser, so the two cannot disagree.

  • The three ZZZ characters of 303 and 304 are valid only as an offset: a signed hour from 00 to 23, UTC or GMT. An abbreviation such as CET, a broken offset (+24) and a lone Z are false.

  • Takes the unescaped element value: "202406151430?+02" is false.

  • Checks the calendar as well as the shape: 29 February 2023, hour 24 and second 60 are false.

  • False for any other code, a code of another kind included; check a code alone with isValidEdifactDtmFormat. False for a non-string argument.

ParameterTypeDescription
valuestringThe data element 2380 value, unescaped (e.g. “202406151430+0200”)
formatEdifactOffsetDateTimeFormatThe data element 2379 format code

boolean indicating validity

import { isValidEdifactOffsetDateTime } from "@northguild/gmt/intermodal/validate";
isValidEdifactOffsetDateTime("202406151430+0200", "205") // true
output 

intermodal/validate/isValidEdifactOffsetDateTime.ts