crystal-sqlite3 icon indicating copy to clipboard operation
crystal-sqlite3 copied to clipboard

Support additional DateTime formats and common datetime queries

Open bcardiff opened this issue 9 years ago • 1 comments

Currently (0.8.1) when reading/writing Time values the format SQLite3::DATE_FORMAT is used. This is one of the supported formats by sqlite. It is actually the one with more precision: YYYY-MM-DD HH:MM:SS.SSS

This is enough for reading/writing values using Time crystal's type. But it would be proper to allow reading time values using a fallback for all other DateTime formats described in https://www.sqlite.org/lang_datefunc.html so the following queries will work:

  • select date('now');
  • select datetime('now');
  • SELECT current_timestamp;

This should be handled in https://github.com/crystal-lang/crystal-sqlite3/blob/97845731523a4e269c4b49599249a11e2c1bd9f5/src/sqlite3/result_set.cr#L59

bcardiff avatar Dec 26 '16 14:12 bcardiff

Suggestion to use %F %T.%L%:z as default time format. Example is 2017-03-24 13:10:29.904-07:00. It includes timezone.

Zhomart avatar Mar 24 '17 20:03 Zhomart