Fable
Fable copied to clipboard
DateTime.MinValue / DateTime.MaxValue ToString("yyyy-MM-dd") issues
Description
DateTime formatting differs between fable and .NET
Fable:
DateTime.MinValue.ToString("yyyy-MM-dd") // '01-01-01'
DateTime.MaxValue.ToString("yyyy-MM-dd") // '10000-01-01'
.NET
DateTime.MinValue.ToString("yyyy-MM-dd") // '0001-01-01'
DateTime.MaxValue.ToString("yyyy-MM-dd") // '9999-01-01'
This leads to a problem when passing a formatted string of DateTime.MinValue / DateTime.MaxValue from the client to the server.
// on the server - hasValue = false
let hasValue, value = DateTimeOffset.TryParseExact(
"01-01-01","yyyy-MM-dd",
CultureInfo.InvariantCulture.DateTimeFormat,
DateTimeStyles.None
)
// on the server - hasValue = false
let hasValue, value = DateTimeOffset.TryParseExact(
"10000-01-01","yyyy-MM-dd",
CultureInfo.InvariantCulture.DateTimeFormat,
DateTimeStyles.None
)