Skip to content

Commit

Permalink
feat: add support for jiff (#526)
Browse files Browse the repository at this point in the history
Adds jiff support with feature jiff01 to be able to handle potential breakage.
When the api names become stable we can consider renaming.
  • Loading branch information
snaggen authored Aug 16, 2024
1 parent b20eeab commit 972ef4f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ actix-files = ["paperclip-core/actix-files"]
actix3-validator = ["paperclip-core/actix3-validator"]
actix4-validator = ["paperclip-core/actix4-validator"]
chrono = ["paperclip-core/chrono"]
jiff01 = ["paperclip-core/jiff01"]
rust_decimal = ["paperclip-core/rust_decimal"]
url = ["paperclip-core/url"]
uuid = ["uuid0","uuid1"]
Expand Down
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ actix-session = { version = "0", optional = true }
actix-identity = { version = "0", optional = true }
actix-files = { version = "0", optional = true }
chrono = { version = "0.4", optional = true }
jiff = { version = "0.1.5", optional = true }
heck = { version = "0.4", optional = true }
once_cell = "1.4"
log = { version = "0.4", optional = true }
Expand Down Expand Up @@ -47,6 +48,7 @@ actix2 = ["actix-base", "actix-web2"]
actix-base = ["v2", "pin-project-lite"]
actix3-validator = ["actix-web-validator2", "validator12"]
actix4-validator = ["actix-web-validator3", "validator14"]
jiff01 = ["jiff"]

# Enable nightly if nightly compiler can be allowed
nightly = ["paperclip-macros/nightly"]
Expand Down
4 changes: 4 additions & 0 deletions core/src/v2/actix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ mod manual_impl {
impl_simple!(usize);
#[cfg(feature = "chrono")]
impl_simple!(chrono::NaiveDateTime);
#[cfg(feature = "jiff01")]
impl_simple!(jiff::Timestamp);
#[cfg(feature = "jiff01")]
impl_simple!(jiff::Zoned);
#[cfg(feature = "rust_decimal")]
impl_simple!(rust_decimal::Decimal);
#[cfg(feature = "url")]
Expand Down
28 changes: 28 additions & 0 deletions core/src/v2/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,34 @@ impl_type_simple!(
DataType::File,
DataTypeFormat::Binary
);
#[cfg(feature = "jiff01")]
impl_type_simple!(jiff::Timestamp, DataType::String, DataTypeFormat::DateTime);
#[cfg(feature = "jiff01")]
impl_type_simple!(
jiff::Zoned,
DataType::String,
DataTypeFormat::Other //RFC 8536
);
#[cfg(feature = "jiff01")]
impl_type_simple!(
jiff::civil::DateTime,
DataType::String,
DataTypeFormat::Other //2024-06-19T15:22:45
);
#[cfg(feature = "jiff01")]
impl_type_simple!(jiff::civil::Date, DataType::String, DataTypeFormat::Date);
#[cfg(feature = "jiff01")]
impl_type_simple!(
jiff::civil::Time,
DataType::String,
DataTypeFormat::Other //15:22:45
);
#[cfg(feature = "jiff01")]
impl_type_simple!(
jiff::Span,
DataType::String,
DataTypeFormat::Other //ISO 8601
);
#[cfg(feature = "chrono")]
impl_type_simple!(
chrono::NaiveDateTime,
Expand Down

0 comments on commit 972ef4f

Please sign in to comment.