Skip to content

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

Open

Description

@JaggerJo

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
)

Activity

  1. changed the title [-]DateTime.MinValue.ToString("yyyy-MM-dd") different result using fable[/-] [+]DateTime.MinValue / DateTime.MaxValue ToString("yyyy-MM-dd") issues[/+] on Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions