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

ToUniversalTime() is not working in online TryFSharp #51

Open
abelbraaksma opened this issue Feb 18, 2022 · 0 comments
Open

ToUniversalTime() is not working in online TryFSharp #51

abelbraaksma opened this issue Feb 18, 2022 · 0 comments

Comments

@abelbraaksma
Copy link
Member

abelbraaksma commented Feb 18, 2022

Not sure whether or not this is a true bug or not, i.e. maybe it's caused by how date and time are dealt with in browsers, but it does lead to differences in how code works in local FSI vs online FSI.

Example code

open System

let x = DateTime.Now
let y = x.ToUniversalTime()
x.Equals y |> printfn "%A"   // should be false
x = y |> printfn "%A"        // should be false
printfn "%A" x               // should be X hours before/after UTC
printfn "%A" y               // should be UTC

Expected output

If you run this, it should output the following (which is what you'll see when running it locally in FSI, except that in UK the times may actually be equal, anywhere else they should be different):

false
false
2/18/2022 6:37:54 PM
2/18/2022 5:37:54 PM

Actual output on https://try.fsharp.org/

However, it outputs this, note specifically the differences in how the %A outputs the time (which may be due to system wide settings on the machine, so not that big a deal), and, most importantly, that ToUniversalTime() did not change the time to UTC, instead the time variable remained unchanged.

true
true
Fri Feb 18 2022 17:09:41 GMT+0100 (Central European Standard Time)
Fri Feb 18 2022 17:09:41 GMT+0100 (Central European Standard Time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant