Class Iso8601Text
- Namespace
- EncDotNet.S100.Validation
- Assembly
- EncDotNet.S100.Core.dll
Recognises and parses ISO 8601 calendar dates, times of day and date-times
written in either the basic format (20260902,
105406Z, 20260902T105406+0000) or the extended format
(2026-09-02, 10:54:06Z, 2026-09-02T10:54:06+00:00).
public static class Iso8601Text
- Inheritance
-
Iso8601Text
- Inherited Members
Remarks
S-100 Part 10c writes HDF5 date and time attributes (issueDate,
issueTime, dateTimeOfFirstRecord, timePoint) in the
basic format, while some producers use the extended one; validation rules
and readers must accept both. Times may carry a decimal fraction of a second
and an optional zone designator (Z, ±hh, ±hhmm or
±hh:mm); a time without one is an ISO 8601 local time. Mixing the two
formats inside a date-time (20260902T10:54:06Z) is accepted because
producers write it and readers tolerate it.
The Is… checks are defined in terms of the TryParse… methods,
so a value that validates is a value the readers can read.
Methods
IsCalendarDate(string?)
true when text is a complete ISO 8601
calendar date in the basic (YYYYMMDD) or extended
(YYYY-MM-DD) format that names a real day.
public static bool IsCalendarDate(string? text)
Parameters
textstringThe text to test; surrounding white space is ignored.
Returns
IsDateOrDateTime(string?)
true when text is an ISO 8601
calendar date (see IsCalendarDate(string?)) or a date-time made of
such a date, the designator T, and a time of day (see
IsTimeOfDay(string?)).
public static bool IsDateOrDateTime(string? text)
Parameters
textstringThe text to test; surrounding white space is ignored.
Returns
IsTimeOfDay(string?)
true when text is an ISO 8601 time of
day in the basic (hhmmss, hhmm, hh) or extended
(hh:mm:ss, hh:mm) format, with an optional decimal fraction
of a second and an optional zone designator.
public static bool IsTimeOfDay(string? text)
Parameters
textstringThe text to test; surrounding white space is ignored.
Returns
TryParseCalendarDate(string?, out DateOnly)
Parses an ISO 8601 calendar date (see IsCalendarDate(string?)).
public static bool TryParseCalendarDate(string? text, out DateOnly date)
Parameters
textstringThe text to parse; surrounding white space is ignored.
dateDateOnlyThe date, when parsing succeeds.
Returns
TryParseDateOrDateTime(string?, out DateTime)
Parses an ISO 8601 calendar date or date-time (see IsDateOrDateTime(string?)) into a UTC time.
public static bool TryParseDateOrDateTime(string? text, out DateTime utc)
Parameters
textstringThe text to parse; surrounding white space is ignored.
utcDateTimeThe time in UTC, with Utc. A date alone is 00:00 of that day; a time without a zone designator is taken as UTC, which is what S-100 producers mean by it.
Returns
TryParseTimeOfDay(string?, out TimeSpan, out TimeSpan?)
Parses an ISO 8601 time of day (see IsTimeOfDay(string?)) into the clock reading and its zone designator.
public static bool TryParseTimeOfDay(string? text, out TimeSpan timeOfDay, out TimeSpan? utcOffset)
Parameters
textstringThe text to parse; surrounding white space is ignored.
timeOfDayTimeSpanThe clock reading as written, before any offset is applied. A fraction of a second is kept to the nearest tick below;
24:00:00(end of day) is one whole day, and a leap second (23:59:60) runs into the next minute.utcOffsetTimeSpan?The offset from UTC: Zero for
Z, the signed offset for±hh/±hhmm/±hh:mm, or null when the time carries no zone (an ISO 8601 local time).