Skip to content

Converting to DateOnly/TimeOnly from string #59253

Closed
@maxkoshevoi

Description

@maxkoshevoi

Related to: dotnet/aspnetcore#36511

Description

DateTime can be converted from string (TypeDescriptor.GetConverter(typeof(DateTime)).ConvertFromString("01.01.0001")), while DateOnly and TimeOnly cannot. This causes some issues. For example, if they are added as query parameters in Asp.Net, they would be represented as 6 and 5 fields respectively instead of one string field (see dotnet/aspnetcore#36511 for more info).

For now, I've created a NuGet with custom type converters to solve this: https://github.com/maxkoshevoi/DateOnlyTimeOnly.AspNet/tree/main/DateOnlyTimeOnly.AspNet/Converters/Type

Are there any plans to enable string to DateOnly/TimeOnly conversion?

Regression?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.DateTimeneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsideration

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions