Resolve date parsing ambiguity when parsing dates when "time/large-dates" feature is enabled
- add explicit delimitter between year and month in date parsing format string - enable "time/large-dates" feature to dev-dependencies resolves #34
This commit is contained in:
@@ -18,4 +18,4 @@ time = { default-features = false, version = "0.3", features = ["formattin
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
quickcheck = "1.0.3"
|
quickcheck = "1.0.3"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
time = { default-features = false, version = "0.3", features = ["formatting", "macros", "parsing", "quickcheck"] }
|
time = { default-features = false, version = "0.3", features = ["formatting", "large-dates", "macros", "parsing", "quickcheck"] }
|
||||||
|
|||||||
14
src/lib.rs
14
src/lib.rs
@@ -515,10 +515,14 @@ fn from_der_(i: &[u8], start_offset: usize) -> Result<Vec<ASN1Block>, ASN1Decode
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let v = format!("{}{}", y_prefix, v);
|
let mut v = format!("{}{}", y_prefix, v);
|
||||||
|
// add a manual delimitter between known year position and rest of the
|
||||||
|
// date string to handle ambiguities when "time/large-dates" feature is
|
||||||
|
// enabled
|
||||||
|
v.insert(4, ':');
|
||||||
|
|
||||||
let format = time::format_description::parse(
|
let format = time::format_description::parse(
|
||||||
"[year][month][day][hour repr:24][minute][second]Z",
|
"[year]:[month][day][hour repr:24][minute][second]Z",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -549,9 +553,13 @@ fn from_der_(i: &[u8], start_offset: usize) -> Result<Vec<ASN1Block>, ASN1Decode
|
|||||||
let idx = v.len() - 1;
|
let idx = v.len() - 1;
|
||||||
v.insert(idx, '0');
|
v.insert(idx, '0');
|
||||||
}
|
}
|
||||||
|
// add a manual delimitter between known year position and rest of the
|
||||||
|
// date string to handle ambiguities when "time/large-dates" feature is
|
||||||
|
// enabled
|
||||||
|
v.insert(4, ':');
|
||||||
|
|
||||||
let format = time::format_description::parse(
|
let format = time::format_description::parse(
|
||||||
"[year][month][day][hour repr:24][minute][second].[subsecond]Z",
|
"[year]:[month][day][hour repr:24][minute][second].[subsecond]Z",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user