Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: System.DateTime.TryParse returns a inconsistent tuple (true, >"Invalid Date"<) #2229

Open
funkr opened this issue Oct 24, 2020 · 1 comment

Comments

@funkr
Copy link

funkr commented Oct 24, 2020

Description

If the returned date is invalid, than the boolean flag must be false.
Must have the same behavoir as on the interactive shell.

Repro code

open System

let validGermanDate = "31.10.2020" 
let invalidAmericanDate = "13/1/2020" 
//let d = invalidAmericanDate
let d = validGermanDate
let r, date = System.DateTime.TryParse d
if r then 
    printfn "Result: %b but the date is: %s -> this not good!" r (date.ToShortDateString ())
else 
    printfn "Result: %b than the date is: %s -> this is ok!" r (date.ToShortDateString ())

Expected and actual results

If TryParse gives back a true than the date must be usable.

On the interactive shell TryParse behaves correct!

Related information

Reproducible on REPL with the given code.

@Zaid-Ajaj
Copy link
Member

Please checkout this comment for a workaround which implements a small module to do the parsing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants