Advise for an API involving dates

We are trying to add support for dates in tantivy, and we need your help on the API.

What should be the type user in the API when the user sets or get the value associated to
the date field in the document.

  • DateTime in the chrono crate seems perfect, but this is not part of the standard library and exposing an external library does not seem like a great idea, as it could lead to a dependency hell. I guess could re-export the chrono crate as tantivy::chrono ?

  • string in ISO_8601 could be ok... but it is a string.

What is the right way to do things here?

1 Like

Re-exporting tantivy::chrono would work fine for me.

Do you make a distinction between fields with timezone and without timezone? (like postgres)

If you're concerned about having chrono as an explicit dependency, you could enable it as a cargo feature and use only for datetimes with timezone. For datetimes without timezone i64 unix timestamp (or std SystemTime) might be a sufficient minimal alternative.


Thanks, we'll probably go for the exporting tantivy::chrono solution then.