Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on overhauling pgrx's `Date`, `Time`, `TimeWithTimeZone`, `Timestamp`, `TimestampWithTimeZone`, and `Interval` types. We now delegate most everything back into Postgres so we're no longer responsible for re-implementing date/time math which is impossible to get correct. The various types can now actually be constructed, and the ones `with time zone` support construction at a specific timezone and also being shifted to a specific timezone. I've also ripped out support for the `time` crate -- the code around that is too much highly-specific knowledge between both Postgres and `time` in order to confidently maintain going forward. Users that use that will need to make their own wrappers to and implement `time` support themselves. Some key changes and features are: - [x] Better error handling -- need to invent a custom error type instead of the generic `PgSqlErrorCodes` - [x] More `impl From` conversions between the types - [x] `impl Add/Sub` - ~~`impl Index` if possible so that `let hour = timestamp[DateTimeParts::Hour];` ~~ not possible - [x] Drastically simplify the `Serialize` implementations and also properly implement the corresponding `Deserialize` trait - [x] doc comments - [x] additional unit tests - [x] top-level constructor functions like `now()`, `current_timestamp()`, etc. - [x] misc. functions from https://www.postgresql.org/docs/15/functions-datetime.html like `age` and `date_trunc` - [x] an example that shows off some of the simple usage
- Loading branch information