Skip to content

Commit d3e362f

Browse files
committed
Support datetime
1 parent a61ebf0 commit d3e362f

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespera_macro/Cargo.toml":"Patch","crates/vespera/Cargo.toml":"Patch","crates/vespera_core/Cargo.toml":"Patch"},"note":"Support datetime, date and time","date":"2026-01-22T10:38:05.323125700Z"}

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vespera_macro/src/parser/schema.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,37 @@ pub(super) fn parse_type_to_schema_ref_with_schemas(
849849
"f32" | "f64" => SchemaRef::Inline(Box::new(Schema::number())),
850850
"bool" => SchemaRef::Inline(Box::new(Schema::boolean())),
851851
"String" | "str" => SchemaRef::Inline(Box::new(Schema::string())),
852+
// Date-time types from chrono crate
853+
"DateTime" | "NaiveDateTime" => SchemaRef::Inline(Box::new(Schema {
854+
format: Some("date-time".to_string()),
855+
..Schema::string()
856+
})),
857+
"NaiveDate" => SchemaRef::Inline(Box::new(Schema {
858+
format: Some("date".to_string()),
859+
..Schema::string()
860+
})),
861+
"NaiveTime" => SchemaRef::Inline(Box::new(Schema {
862+
format: Some("time".to_string()),
863+
..Schema::string()
864+
})),
865+
// Date-time types from time crate
866+
"OffsetDateTime" | "PrimitiveDateTime" => SchemaRef::Inline(Box::new(Schema {
867+
format: Some("date-time".to_string()),
868+
..Schema::string()
869+
})),
870+
"Date" => SchemaRef::Inline(Box::new(Schema {
871+
format: Some("date".to_string()),
872+
..Schema::string()
873+
})),
874+
"Time" => SchemaRef::Inline(Box::new(Schema {
875+
format: Some("time".to_string()),
876+
..Schema::string()
877+
})),
878+
// Duration types
879+
"Duration" => SchemaRef::Inline(Box::new(Schema {
880+
format: Some("duration".to_string()),
881+
..Schema::string()
882+
})),
852883
// Standard library types that should not be referenced
853884
// Note: HashMap and BTreeMap are handled above in generic types
854885
"Vec" | "Option" | "Result" | "Json" | "Path" | "Query" | "Header" => {

0 commit comments

Comments
 (0)