Skip to content

Commit 4effd74

Browse files
authored
Add custom Duration and Timestamp types for conversion with serde (#89)
* 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
1 parent d20a7f4 commit 4effd74

File tree

3 files changed

+569
-4
lines changed

3 files changed

+569
-4
lines changed

interpreter/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cel-parser = { path = "../parser", version = "0.8.0" }
1313

1414
nom = "7.1.3"
1515

16-
chrono = { version = "0.4", default-features = false, features = ["alloc"], optional = true }
16+
chrono = { version = "0.4", default-features = false, features = ["alloc", "serde"], optional = true }
1717
regex = { version = "1.10.5", optional = true }
1818
serde = "1.0"
1919
serde_json = { version = "1.0", optional = true }

interpreter/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ mod resolvers;
2020

2121
#[cfg(feature = "chrono")]
2222
mod duration;
23+
#[cfg(feature = "chrono")]
24+
pub use ser::{Duration, Timestamp};
2325

2426
mod ser;
2527
pub use ser::to_value;

0 commit comments

Comments
 (0)