---
title: Build a DateTime from EDI date/time strings
summary: Parse a DateTime from EDI-style date and time strings.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
operation_id: OP-010
trigger: Caller parses a date/time from a fixed-format interchange file*
---

# 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

1. 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](../business-rules.md#br-028-in-edi-date-parsing%2C-a-6-character-date-is-a-2-digit-year-and-is-always-treated-as-21st-century))
2. Right-pad the time string to 6 characters with `'0'`. ([BR-029](../business-rules.md#br-029-a-short-edi-time-string-is-right-padded-with-zeros-to-hh24miss))
3. 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`.
4. Construct and return `new DateTime(year, month, day, hour, minute, second)`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
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` (from `Substring`) or `FormatException` (from `Convert.ToInt32`); an out-of-range month/day raises `ArgumentOutOfRangeException` from the `DateTime` constructor.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **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`
