---
title: Convert EDI date/time strings
summary: Convert between EDI date/time string representations and DateTime via DateMaker.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common.Files
reference_type: package
operation_id: OP-12
trigger: Fill/Build of every date-bearing segment (BHT, GS, ISA, DTM, DTP, BPR, DMG, HI, STC)
---

# Convert EDI date/time strings

`DateMaker` (declared in namespace `SAIF.Common` despite living under `Edi\Core\`) converts between EDI date/time string representations and `DateTime`, and is called from every date-bearing segment's `Fill`/`Build` in [Map a segment to/from a typed segment object](map-segment-to-typed-object.md).

| Field | Value |
| --- | --- |
| **Operation ID** | OP-12 |
| **Trigger** | `Fill`/`Build` of every date-bearing segment (`BHT`, `GS`, `ISA`, `DTM`, `DTP`, `BPR`, `DMG`, `HI`, `STC`). |
| **Inputs/Outputs** | EDI date/time strings ⇄ `DateTime`. |
| **Primary components** | `DateMaker.MakeDateTime`, `DateMaker.ExtractDateRange`, `DateMaker.EdiFileDateString` |
| **Entry point** | `Common\SAIF.Common.Files\Edi\Core\DateMaker.cs` |

## Steps

1. `MakeDateTime(date, time = "000000")` left-pads a 6-character date with `"20"` ([BR-056](../business-rules.md#br-056-two-digit-edi-years-interpreted-as-21st-century)), right-pads the time to 6 characters with `'0'` ([BR-057](../business-rules.md#br-057-edi-time-value-right-padded-before-conversion)), and composes a `DateTime` from the yyyy/MM/dd + HH/mm/ss substrings.
2. `ExtractDateRange(string, out DateTime, out DateTime)` splits on `'-'` and converts both halves through `MakeDateTime` ([BR-058](../business-rules.md#br-058-edi-date-range-format)).
3. `EdiFileDateString(DateTime, DateTime?)` formats `yyyyMMdd`, appending `-yyyyMMdd` when an end date is supplied ([BR-058](../business-rules.md#br-058-edi-date-range-format)).

## Process flow

```mermaid
flowchart TD
	Start([Date-bearing segment Fill/Build]) --> Which{Single date, range, or format?}
	Which -->|Parse single| Make["MakeDateTime<br>pad date with 20, pad time to HHmmss"]
	Which -->|Parse range| Range["ExtractDateRange<br>split on - then MakeDateTime each half"]
	Which -->|Format for output| Format["EdiFileDateString<br>yyyyMMdd, optional -yyyyMMdd"]
	Make --> EndOk([DateTime value])
	Range --> EndOk
	Format --> EndOut([Formatted EDI date string])
```

## Failure and edge-case behavior
- Two-digit EDI years are always interpreted as 21st-century — there is no 20th-century fallback, so a source system emitting genuinely 20th-century dates would be misinterpreted ([BR-056](../business-rules.md#br-056-two-digit-edi-years-interpreted-as-21st-century)).
- A partial time value (fewer than 6 characters) has its missing trailing components default to zero rather than raising an error ([BR-057](../business-rules.md#br-057-edi-time-value-right-padded-before-conversion)).
- `DateTimeBuilder` (internal, `Edi\Core\Builders\`) duplicates `DateMaker.MakeDateTime` and has no caller in this library — presumed dead code.*

## 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.Files\Edi\Core\DateMaker.cs
- Common\SAIF.Common.Files\Edi\Core\Builders\DateTimeBuilder.cs
