Skip to content

Commit 466d3e1

Browse files
committedOct 14, 2023
Make parse<DateTime> return a UTC DateTime
Otherwise it will depend on the local machine, you can always convert it to Local afterwards if desired.
1 parent 21f4a0b commit 466d3e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/FSharpPlus/Control/Converter.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ type Parse =
164164
static member Parse (_: DateTime , _: Parse) = fun (x:string) ->
165165
match DateTime.TryParseExact (x, [|"yyyy-MM-ddTHH:mm:ss.fffZ"; "yyyy-MM-ddTHH:mm:ssZ"|], null, DateTimeStyles.RoundtripKind) with
166166
| true, x -> x
167-
| _ -> DateTime.Parse (x, CultureInfo.InvariantCulture)
167+
| _ -> DateTime.Parse (x, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal)
168168

169169
static member Parse (_: DateTimeOffset, _: Parse) = fun (x:string) ->
170170
try DateTimeOffset.ParseExact (x, [|"yyyy-MM-ddTHH:mm:ss.fffK"; "yyyy-MM-ddTHH:mm:ssK"|], null, DateTimeStyles.AssumeUniversal)

0 commit comments

Comments
 (0)
Please sign in to comment.