|
37 | 37 | //!
|
38 | 38 | //! | Rust type | Sqlite type(s) |
|
39 | 39 | //! |---------------------------------------|------------------------------------------------------|
|
40 |
| -//! | `chrono::NaiveDateTime` | DATETIME | |
41 |
| -//! | `chrono::DateTime<Utc>` | DATETIME | |
42 |
| -//! | `chrono::DateTime<Local>` | DATETIME | |
43 |
| -//! | `chrono::NaiveDate` | DATE | |
44 |
| -//! | `chrono::NaiveTime` | TIME | |
| 40 | +//! | `chrono::NaiveDateTime` | DATETIME (TEXT, INTEGER, REAL) | |
| 41 | +//! | `chrono::DateTime<Utc>` | DATETIME (TEXT, INTEGER, REAL) | |
| 42 | +//! | `chrono::DateTime<Local>` | DATETIME (TEXT, INTEGER, REAL) | |
| 43 | +//! | `chrono::DateTime<FixedOffset>` | DATETIME (TEXT, INTEGER, REAL) | |
| 44 | +//! | `chrono::NaiveDate` | DATE (TEXT only) | |
| 45 | +//! | `chrono::NaiveTime` | TIME (TEXT only) | |
| 46 | +//! |
| 47 | +//! ##### NOTE: `DATETIME` conversions |
| 48 | +//! SQLite may represent `DATETIME` values as one of three types: `TEXT`, `REAL`, or `INTEGER`. |
| 49 | +//! Which one is used is entirely up to you and how you store timestamps in your database. |
| 50 | +//! |
| 51 | +//! The deserialization for `NaiveDateTime`, `DateTime<Utc>` and `DateTime<Local>` infer the date |
| 52 | +//! format from the type of the value they're being decoded from: |
| 53 | +//! |
| 54 | +//! * If `TEXT`, the format is assumed to be an ISO-8601 compatible datetime string. |
| 55 | +//! A number of possible formats are tried; see `sqlx-sqlite/src/types/chrono.rs` for the current |
| 56 | +//! set of formats. |
| 57 | +//! * If `INTEGER`, it is expected to be the number of seconds since January 1, 1970 00:00 UTC, |
| 58 | +//! as if returned from the `unixtime()` function (without the `subsec` modifier). |
| 59 | +//! * If `REAL`, it is expected to be the (possibly fractional) number of days since the Julian epoch, |
| 60 | +//! November 24, 4714 BCE 12:00 UTC, as if returned from the `julianday()` function. |
| 61 | +//! |
| 62 | +//! These types will always encode to a datetime string, either |
| 63 | +//! with (`DateTime<Tz>` for any `Tz: TimeZone`) or without (`NaiveDateTime`) a timezone offset. |
45 | 64 | //!
|
46 | 65 | //! ### [`time`](https://crates.io/crates/time)
|
47 | 66 | //!
|
48 | 67 | //! Requires the `time` Cargo feature flag.
|
49 | 68 | //!
|
50 | 69 | //! | Rust type | Sqlite type(s) |
|
51 | 70 | //! |---------------------------------------|------------------------------------------------------|
|
52 |
| -//! | `time::PrimitiveDateTime` | DATETIME | |
53 |
| -//! | `time::OffsetDateTime` | DATETIME | |
54 |
| -//! | `time::Date` | DATE | |
55 |
| -//! | `time::Time` | TIME | |
| 71 | +//! | `time::PrimitiveDateTime` | DATETIME (TEXT, INTEGER) | |
| 72 | +//! | `time::OffsetDateTime` | DATETIME (TEXT, INTEGER) | |
| 73 | +//! | `time::Date` | DATE (TEXT only) | |
| 74 | +//! | `time::Time` | TIME (TEXT only) | |
| 75 | +//! |
| 76 | +//! ##### NOTE: `DATETIME` conversions |
| 77 | +//! The behavior here is identical to the corresponding `chrono` types, minus the support for `REAL` |
| 78 | +//! values as Julian days (it's just not implemented). |
56 | 79 | //!
|
57 | 80 | //! ### [`uuid`](https://crates.io/crates/uuid)
|
58 | 81 | //!
|
|
0 commit comments