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 for DataTime/DateTimeOffset loses precision #358

Closed kostrse closed 4 years ago

kostrse commented 7 years ago

SaveCsv/WriteCsv uses a default G DateTime formatter which loses information about time zone and milliseconds.

The more widespread nowadays, and precise, is ISO 8601 format:

2009-06-15T13:45:30.0000000-07:00

instead of a format used by WriteCsv:

04/10/2008 06:30:00

The code for reference is here:

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

Related: #355

tpetricek commented 7 years ago

This sounds like a reasonable change to the default behaviour to me - could you send a PR changing the default?