Closed jmcnamara closed 2 years ago
Thanks for the questions @jmcnamara. In your specific case NaiveDateTime
, NaiveDate
and NaiveTime
are probably most suitable for representing the equivalent types in Excel. We will likely rename NaiveTime
and NaiveDate
in future to just Time
and Date
which will promote them a bit better as choices, while deprecating Date<Tz>
. DateTime<Utc>
is probably a sub-optimal choice however as I think users entering timestamps in an Excel file would probably view these as Local
/Naive
timestamps.
Thanks. I appreciate the feedback. Closing.
This is a question and not an issue. I didn't see a specific Chrono forum so I am asking here. Apologies if it isn't the right place.
I am writing an Excel xlsx writing library in rust and would like to use chrono::DateTime as the type for API functions/methods for writing Excel date and times.
Datetimes in Excel are a serial date with days counted from an epoch (generally 1899-12-31) and the time as a percentage/decimal of the seconds in the day. Both are stored in the same f64 value, for example,
2022/09/17 12:00:00
is stored as 44821.5 with a separate numeric format likeyyyy/mm/dd hh:mm
. (Excel can save dates in a text ISO 8601 format in "Strict Open XML Spreadsheet" format but in practice this is rarely used.) Excel also doesn't use timezones or try to convert or encode timezone information in any way.I am looking for some advice on what you think might be suitable types for the functions/method. I plan to use
DateTime<Utc>
,Date<Utc>
andNaiveTime
for date-times, dates, and time respectively. However since there aren't any timezones involved maybeNaiveDateTime
andNaiveDate
are better. At the same time they seem, from the documentation, to be lower level types so they may not be suitable for general APIs. And also I see some discussion about deprecatingNaiveDate
.Here is a sample rust main with a conversion function for reference:
Any advice is appreciated.