DateMaker¶
DateMaker converts between EDI date/time string representations and DateTime, and is used by every date-bearing segment (BHT, GS, ISA, DTM, DTP, BPR, DMG, HI, STC) to translate their raw element values into usable DateTime values and back. Its file declares namespace SAIF.Common rather than a namespace under SAIF.Common.Files.Edi, even though it lives at Edi\Core\DateMaker.cs and is exclusively consumed by this library's EDI segment types — a namespace anomaly relative to the rest of the Edi.Core folder.
Purpose¶
- Converts a 6- or 8-digit EDI date string plus an optional time string into a
DateTime, left-padding a 6-character date with"20"so all 2-digit years are interpreted as 21st century (BR-056), and right-padding the time string toHHmmsswith trailing zeros before conversion (BR-057). - Splits an EDI date-range string on the
-separator into a start and endDateTime(BR-058). - Formats one or two
DateTimevalues back into the EDIyyyyMMddoryyyyMMdd-yyyyMMddstring form (BR-058).
Context¶
- Namespace:
SAIF.Common - Assembly/package:
SAIF.Framework.Common.Files
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| DateSeperator | const char DateSeperator = '-' |
The delimiter character used to separate a start date from an end date in an EDI date-range string (BR-058). |
| DateFormat | const string DateFormat = "yyyyMMdd" |
The DateTime.ToString/parse format string used for a single EDI date component. |
| MakeDateTime | static DateTime MakeDateTime(string date, string time = "000000") |
Converts date (6-digit yymmdd or 8-digit yyyymmdd) and time (hh24miss, defaulting to midnight) into a DateTime; prefixes a 6-character date with "20" (BR-056) and right-pads time to 6 characters with '0' before extracting year/month/day/hour/minute/second (BR-057). |
| ExtractDateRange | static void ExtractDateRange(string dateString, out DateTime startDate, out DateTime endDate) |
Splits dateString on DateSeperator (BR-058) and converts each half to a DateTime via MakeDateTime, returning them through the startDate/endDate output parameters. |
| EdiFileDateString | static string EdiFileDateString(DateTime startDate, DateTime? endDate) |
Formats startDate as yyyyMMdd; if endDate is supplied, appends DateSeperator followed by endDate formatted as yyyyMMdd, producing the EDI date-range string form (BR-058). |
Behavioral notes¶
- An internal, uncalled
DateTimeBuilderclass (Edi\Core\Builders\DateTimeBuilder.cs) duplicates the same date/time-parsing logic asMakeDateTimebut is never referenced anywhere in this library and appears to be dead code*. MakeDateTime's time-padding behavior differs subtly fromDateTimeBuilder.Build:MakeDateTimeright-padstimeto 6 characters before substring extraction (BR-057), whileDateTimeBuilder.Builddoes not pad at all and would throw on a short time string*.
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
- Common\SAIF.Common.Files\Edi\Core\DateMaker.cs