fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
929 stars 196 forks source link

SaveCsv doesn't handle DateTimeOffset properly #355

Closed mweerden closed 4 years ago

mweerden commented 8 years ago

The following code from FrameUtils.fs (lines 314-316) is where the problem is:

    formatter (fun (dt:System.DateTimeOffset) ->
      if dt.TimeOfDay = TimeSpan.Zero then dt.Date.ToString("d", ci)
      else dt.DateTime.ToString(ci)) ] |> dict

Here dt.DateTime does not have the offset information, which will result in ToString just assuming the local time zone when required.

The other case is also not right, as the output will normally not include the offset with "d".

It's probably best to just use formatter (fun (dt:System.DateTimeOffset) -> dt.ToString(ci)) instead. (Personally, I would do the same for DateTime.)