|
65 | 65 | //! November 24, 4714 BCE 12:00 UTC, as if returned from the `julianday()` function.
|
66 | 66 | //!
|
67 | 67 | //! These types will always encode to a datetime string, either
|
68 |
| -//! with (`DateTime<Tz>` for any `Tz: TimeZone`) or without (`NaiveDateTime`) a timezone offset. |
| 68 | +//! with a timezone offset (`DateTime<Tz>` for any `Tz: TimeZone`) or without (`NaiveDateTime`). |
| 69 | +//! |
| 70 | +//! ##### NOTE: `CURRENT_TIMESTAMP` and comparison/interoperability of `DATETIME` values |
| 71 | +//! As stated previously, `DateTime<Tz>` always encodes to a date-time string |
| 72 | +//! _with_ a timezone offset, |
| 73 | +//! in [RFC 3339 format][::chrono::DateTime::to_rfc3339_opts] (with `use_z: false`). |
| 74 | +//! |
| 75 | +//! However, most of SQLite's datetime functions |
| 76 | +//! (including `datetime()` and `DEFAULT CURRENT_TIMESTAMP`) |
| 77 | +//! do not use this format. They instead use `YYYY-MM-DD HH:MM:SS.SSSS` without a timezone offset. |
| 78 | +//! |
| 79 | +//! This may cause problems with interoperability with other applications, and especially |
| 80 | +//! when comparing datetime values, which compares the actual string values lexicographically. |
| 81 | +//! |
| 82 | +//! Date-time strings in the SQLite format will generally _not_ compare consistently |
| 83 | +//! with date-time strings in the RFC 3339 format. |
| 84 | +//! |
| 85 | +//! We recommend that you decide up-front whether `DATETIME` values should be stored |
| 86 | +//! with explicit time zones or not, and use the corresponding type |
| 87 | +//! (and its corresponding offset, if applicable) _consistently_ throughout your |
| 88 | +//! application: |
| 89 | +//! |
| 90 | +//! * RFC 3339 format: `DateTime<Tz>` (e.g. `DateTime<Utc>`, `DateTime<Local>`, `DateTime<FixedOffset>`) |
| 91 | +//! * Changing or mixing and matching offsets may break comparisons with existing timestamps. |
| 92 | +//! * `DateTime<Local>` is **not recommended** for portable applications. |
| 93 | +//! * `DateTime<FixedOffset>` is only recommended if the offset is **constant**. |
| 94 | +//! * SQLite format: `NaiveDateTime` |
| 95 | +//! |
| 96 | +//! Note that non-constant offsets may still cause issues when comparing timestamps, |
| 97 | +//! as the comparison operators are not timezone-aware. |
69 | 98 | //!
|
70 | 99 | //! ### [`time`](https://crates.io/crates/time)
|
71 | 100 | //!
|
|
82 | 111 | //! The behavior here is identical to the corresponding `chrono` types, minus the support for `REAL`
|
83 | 112 | //! values as Julian days (it's just not implemented).
|
84 | 113 | //!
|
| 114 | +//! `PrimitiveDateTime` and `OffsetDateTime` will always encode to a datetime string, either |
| 115 | +//! with a timezone offset (`OffsetDateTime`) or without (`PrimitiveDateTime`). |
| 116 | +//! |
| 117 | +//! ##### NOTE: `CURRENT_TIMESTAMP` and comparison/interoperability of `DATETIME` values |
| 118 | +//! As stated previously, `OffsetDateTime` always encodes to a datetime string _with_ a timezone offset, |
| 119 | +//! in [RFC 3339 format][::time::format_description::well_known::Rfc3339] (using `Z` for UTC offsets). |
| 120 | +//! |
| 121 | +//! However, most of SQLite's datetime functions |
| 122 | +//! (including `datetime()` and `DEFAULT CURRENT_TIMESTAMP`) |
| 123 | +//! do not use this format. They instead use `YYYY-MM-DD HH:MM:SS.SSSS` without a timezone offset. |
| 124 | +//! |
| 125 | +//! This may cause problems with interoperability with other applications, and especially |
| 126 | +//! when comparing datetime values, which compares the actual string values lexicographically. |
| 127 | +//! |
| 128 | +//! Date-time strings in the SQLite format will generally _not_ compare consistently |
| 129 | +//! with date-time strings in the RFC 3339 format. |
| 130 | +//! |
| 131 | +//! We recommend that you decide up-front whether `DATETIME` values should be stored |
| 132 | +//! with explicit time zones or not, and use the corresponding type |
| 133 | +//! (and its corresponding offset, if applicable) _consistently_ throughout your |
| 134 | +//! application: |
| 135 | +//! |
| 136 | +//! * RFC 3339 format: `OffsetDateTime` with a **constant** offset. |
| 137 | +//! * Changing or mixing and matching offsets may break comparisons with existing timestamps. |
| 138 | +//! * `OffsetDateTime::now_local()` is **not recommended** for portable applications. |
| 139 | +//! * Non-UTC offsets are only recommended if the offset is **constant**. |
| 140 | +//! * SQLite format: `PrimitiveDateTime` |
| 141 | +//! |
| 142 | +//! Note that non-constant offsets may still cause issues when comparing timestamps, |
| 143 | +//! as the comparison operators are not timezone-aware. |
| 144 | +//! |
85 | 145 | //! ### [`uuid`](https://crates.io/crates/uuid)
|
86 | 146 | //!
|
87 | 147 | //! Requires the `uuid` Cargo feature flag.
|
|
0 commit comments