Table of Contents

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

value string

The string to parse. A null string gives no value.

Returns

Maybe<DateTime>

A Maybe<T> containing the parsed value, and one containing no value if value does 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

value string

The string to parse. A null string gives no value.

provider IFormatProvider

The formatting information of the culture to read with.

styles DateTimeStyles

The formatting options permitted in value.

Returns

Maybe<DateTime>

A Maybe<T> containing the parsed value, and one containing no value if value does not hold one.

Remarks