Method TryParseDateTime
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
TryParseDateTime(string?)
Parses a DateTime from this string, if it holds one.
[Pure]
public static Maybe<DateTime> TryParseDateTime(this string? value)
Parameters
Returns
- Maybe<DateTime>
A Maybe<T> containing the parsed value, and one containing no value if
valuedoes not hold one.
Remarks
Wraps TryParse(string, out DateTime), so this reads
the current culture. Date text is where that matters most, because
03/04/2026 is two different days and this changes with the culture
that reads it. Thus, prefer
TryParseDateTime(string?, IFormatProvider, DateTimeStyles) for
text that the user did not type.
TryParseDateTime(string?, IFormatProvider, DateTimeStyles)
Parses a DateTime from this string in the given culture and style, if it holds one.
[Pure]
public static Maybe<DateTime> TryParseDateTime(this string? value, IFormatProvider provider, DateTimeStyles styles)
Parameters
valuestringThe string to parse. A null string gives no value.
providerIFormatProviderThe formatting information of the culture to read with.
stylesDateTimeStylesThe formatting options permitted in
value.
Returns
- Maybe<DateTime>
A Maybe<T> containing the parsed value, and one containing no value if
valuedoes not hold one.