- Notifications
You must be signed in to change notification settings - Fork104
Open
Description
Background and motivation
There is currently formats related to DateTime:
"yyyy-MM-ddTHH:mm:ss.fffZ"; "yyyy-MM-ddTHH:mm:ssZ"and DateTimeOffset:
"yyyy-MM-ddTHH:mm:ss.fffK"; "yyyy-MM-ddTHH:mm:ssK"These look related to ISO 8601. See the roundtrip format in:
https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings
And the page on the standard on wikipedia:
https://en.wikipedia.org/wiki/ISO_8601
API Proposal
Modules in the Extensions.InvariantCulture namespace named DateTime and DateTimeOffset with related functions. Move the implementation of TryParse and Parse of DateTime and DateTimeOffset to these modules.
namespaceFSharpPlus.Extensions.InvariantCulture[<RequireQualifiedAccess>]moduleDateTime=lettryParse(x:string)=match DateTime.TryParseExact(x,[|"yyyy-MM-ddTHH:mm:ss.fffZ";"yyyy-MM-ddTHH:mm:ssZ"|],null, DateTimeStyles.RoundtripKind)with|true, x-> Some x|_->match DateTime.TryParse(x, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal)with|true, x-> Some x|_-> None
API Usage
openFSharpPlus.Extensionsletparsed= InvariantCulture.DateTime.tryParse stringFromTheInternet
Alternative Designs
No response
Risks
Probably little risk
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
Yes, please assign this issue to me.
Metadata
Metadata
Assignees
Labels
No labels