Fable icon indicating copy to clipboard operation
Fable copied to clipboard

DateTime.MinValue / DateTime.MaxValue ToString("yyyy-MM-dd") issues

Open JaggerJo opened this issue 5 years ago • 0 comments

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
)

JaggerJo avatar Sep 07 '20 15:09 JaggerJo