Build a DateTime from EDI date/time strings¶
Parse a DateTime from EDI-style date and time strings, triggered when caller parses a date/time from a fixed-format interchange file*.
| Field | Value |
|---|---|
| Operation ID | OP-010 |
| Trigger | Caller parses a date/time from a fixed-format interchange file* |
| Inputs | date (yyyymmdd or yymmdd), time (hh24miss) |
| Outputs | DateTime |
| Primary components | SAIF.Common.DateMaker.MakeDateTime(string date, string time = "000000") |
| Entry point | Common/SAIF.Common/Classes/DateMaker.cs |
Steps¶
- If the date string is exactly 6 characters, prefix it with
"20"— all 2-digit years are treated as 21st century (stated in the method's<comments>block). (BR-028) - Right-pad the time string to 6 characters with
'0'. (BR-029) - Slice year (0,4), month (4,2), day (6,2) from the date string and hour (0,2), minute (2,2), second (4,2) from the time string, converting each with
Convert.ToInt32. - Construct and return
new DateTime(year, month, day, hour, minute, second).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Caller parses date/time string]) --> D1{"Date string is<br>exactly 6 chars?"}
D1 -->|Yes| S1a["Prefix date<br>string with '20'"]
D1 -->|No| S2
S1a --> S2["Right-pad time string<br>to 6 chars with '0'"]
S2 --> S3["Slice year/month/day from date,<br>hour/min/sec from time"]
S3 --> S4["Construct DateTime<br>from parsed values"]
S4 --> End([Return DateTime])
Failure and edge-case behavior¶
- No try/catch and no argument guard. A malformed or short date string raises
ArgumentOutOfRangeException(fromSubstring) orFormatException(fromConvert.ToInt32); an out-of-range month/day raisesArgumentOutOfRangeExceptionfrom theDateTimeconstructor.*
Related documentation¶
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/Classes/DateMaker.cs