---
title: DateMaker
summary: API reference for DateMaker.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common.Files
reference_type: package
---

# 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](../../business-rules.md#br-056-two-digit-edi-years-interpreted-as-21st-century)), and right-padding the time string to `HHmmss` with trailing zeros before conversion ([BR-057](../../business-rules.md#br-057-edi-time-value-right-padded-before-conversion)).
- Splits an EDI date-range string on the `-` separator into a start and end `DateTime` ([BR-058](../../business-rules.md#br-058-edi-date-range-format)).
- Formats one or two `DateTime` values back into the EDI `yyyyMMdd` or `yyyyMMdd-yyyyMMdd` string form ([BR-058](../../business-rules.md#br-058-edi-date-range-format)).

## 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](../../business-rules.md#br-058-edi-date-range-format)). |
| 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](../../business-rules.md#br-056-two-digit-edi-years-interpreted-as-21st-century)) and right-pads `time` to 6 characters with `'0'` before extracting year/month/day/hour/minute/second ([BR-057](../../business-rules.md#br-057-edi-time-value-right-padded-before-conversion)). |
| ExtractDateRange | `static void ExtractDateRange(string dateString, out DateTime startDate, out DateTime endDate)` | Splits `dateString` on `DateSeperator` ([BR-058](../../business-rules.md#br-058-edi-date-range-format)) 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](../../business-rules.md#br-058-edi-date-range-format)). |

## Behavioral notes
- An internal, uncalled `DateTimeBuilder` class (`Edi\Core\Builders\DateTimeBuilder.cs`) duplicates the same date/time-parsing logic as `MakeDateTime` but is never referenced anywhere in this library and appears to be dead code*.
- `MakeDateTime`'s time-padding behavior differs subtly from `DateTimeBuilder.Build`: `MakeDateTime` right-pads `time` to 6 characters before substring extraction ([BR-057](../../business-rules.md#br-057-edi-time-value-right-padded-before-conversion)), while `DateTimeBuilder.Build` does 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
