Skip to content

Commit

Permalink
fix date parsing when set_dates_to is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseditson committed Feb 24, 2025
1 parent 8f383d4 commit 5263340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/fields/field_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,12 @@ impl FieldType {
schema.insert("description".into(), description.into());
schema.insert("type".into(), "string".into());
if let Some(date) = options.set_dates_to {
schema.insert(
"const".into(),
date.format(
&time::format_description::parse("YYYY-MM-DD HH:MM:SS").unwrap(),
)
.unwrap()
.into(),
);
let fmt = time::format_description::parse(
"[year]-[month]-[day] [hour]:[minute]:[second]",
)
.unwrap();
let date_str = date.with_time(time::Time::MIDNIGHT).format(&fmt).unwrap();
schema.insert("const".into(), date_str.into());
} else {
schema.insert("format".into(), "date".into());
}
Expand Down
1 change: 1 addition & 0 deletions src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ impl Site {
objects.push(obj);
}
Err(err) => {
println!("Invalid file {:?}: {}", path, err);
error!("Invalid file {:?}: {}", path, err);
}
}
Expand Down

0 comments on commit 5263340

Please sign in to comment.