Skip to content

Commit

Permalink
Add custom Duration and Timestamp types for conversion with serde (#89)
Browse files Browse the repository at this point in the history
* Add custom Duration and Timestamp types for conversion with serde

* Update serde example with Duration and Timestamps

* Improve duration and timestamp serde example, fix copied test var name.

* Move Duration and Timestamp examples to respective types docs

* Refactor Duration and Timestamp to be compatible with other parsers

* Manually serialize Timestamps

* Use chrono::DateTime serialization impl

* Put Duration and Timestamp types behind chrono feature

* Fix lint for SerializeTimestamp

* Combine json time-type tests

* Add SAFTEY comments to asserts for TimeSerializer

* Replace TimeSerializer asserts with errors
  • Loading branch information
fore5fire authored Nov 19, 2024
1 parent d20a7f4 commit 4effd74
Show file tree
Hide file tree
Showing 3 changed files with 569 additions and 4 deletions.
2 changes: 1 addition & 1 deletion interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cel-parser = { path = "../parser", version = "0.8.0" }

nom = "7.1.3"

chrono = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
chrono = { version = "0.4", default-features = false, features = ["alloc", "serde"], optional = true }
regex = { version = "1.10.5", optional = true }
serde = "1.0"
serde_json = { version = "1.0", optional = true }
Expand Down
2 changes: 2 additions & 0 deletions interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ mod resolvers;

#[cfg(feature = "chrono")]
mod duration;
#[cfg(feature = "chrono")]
pub use ser::{Duration, Timestamp};

mod ser;
pub use ser::to_value;
Expand Down
Loading

0 comments on commit 4effd74

Please sign in to comment.