Skip to content

Commit ca388df

Browse files
committed
Allow created date to be set by the user when exporting STEP
1 parent dbb6fb8 commit ca388df

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

modeling-cmds/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212

1313
[dependencies]
1414
anyhow = "1.0.97"
15-
chrono = "0.4.39"
15+
chrono = { version = "0.4.39", features = ["serde"] }
1616
cxx = { version = "1.0", optional = true }
1717
data-encoding = "2.8.0"
1818
enum-iterator = "2.1.0"

modeling-cmds/src/datetime.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
use schemars::JsonSchema;
2+
use serde::{Deserialize, Serialize};
3+
14
/// A wrapper for chrono types, since we need to impl Value for them.
2-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default)]
5+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default, Deserialize, Serialize, JsonSchema)]
36
pub struct DateTimeLocal {
47
value: chrono::DateTime<chrono::Local>,
58
}

modeling-cmds/src/format/step.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use schemars::JsonSchema;
33
use serde::{Deserialize, Serialize};
44

55
use crate::coord;
6+
use crate::datetime::DateTimeLocal;
67

78
/// Import models in STEP format.
89
pub mod import {
@@ -38,12 +39,9 @@ pub mod export {
3839
///
3940
/// [KittyCAD co-ordinate system]: ../coord/constant.KITTYCAD.html
4041
pub coords: coord::System,
42+
4143
/// Timestamp override.
42-
///
43-
/// This is intended for local integration testing only; it is not provided as an option
44-
/// in the JSON schema.
45-
#[serde(skip)]
46-
pub created: Option<chrono::DateTime<chrono::Utc>>,
44+
pub created: Option<DateTimeLocal>,
4745
}
4846

4947
impl Default for Options {

0 commit comments

Comments
 (0)