Class RedbTemporalFormat
Invariant, round-trip text form for the zone-less temporal types
(, , ).
Both the JSON converters and the _values._String write path go through here, so the
two can never disagree and neither depends on the ambient .
Why this exists. Three distinct culture leaks, only the first of which is obvious:
A bare DateOnly.ToString() / TimeOnly.ToString() uses the CURRENT
culture's short date/time pattern: "23.08.2026" under ru-RU, "8/23/2026" under
en-US, "2:30 PM" for a time. This is what the _values._String write path used
to do, so a value written under one culture failed to parse, or silently mis-parsed with day
and month swapped, under another.Parse / TryParse without an explicit reads
back through the current culture, so the read side drifted with the write side.Even an explicit custom pattern is only partly safe: in a custom format string
':' resolves to the culture's TIME SEPARATOR ('-' and '.' are literals,
only '/' is the date separator). Most cultures use ':', which is exactly why
this one hid.
The standard round-trip specifiers used here ("O" for the two date/time types,
"c" for ) are culture-independent by definition.
additionally used to be written as @"hh\:mm\:ss", which drops
the day component and the sign: 3.02:00:00 came back as 02:00:00. "c"
is the constant format [-][d'.']hh':'mm':'ss['.'fffffff] and keeps both.
Parsing accepts the invariant form first and falls back to the current culture last, so rows
written by an earlier build under a non-invariant culture keep loading on a host that still
runs under that culture.
public static class RedbTemporalFormat
Inheritance
Methods
ToText(DateOnly)
public static string ToText(DateOnly value)
ToText(TimeOnly)
public static string ToText(TimeOnly value)
ToText(TimeSpan)
public static string ToText(TimeSpan value)
TryParseDateOnly(string?, out DateOnly)
public static bool TryParseDateOnly(string? text, out DateOnly value)
TryParseTimeOnly(string?, out TimeOnly)
public static bool TryParseTimeOnly(string? text, out TimeOnly value)
TryParseTimeSpan(string?, out TimeSpan)
public static bool TryParseTimeSpan(string? text, out TimeSpan value)