MCPcopy Create free account
hub / github.com/Open-Quant/openquant / parse_naive_datetimes

Function parse_naive_datetimes

crates/pyopenquant/src/helpers.rs:26–37  ·  view source on GitHub ↗
(values: Vec<String>)

Source from the content-addressed store, hash-verified

24}
25
26pub fn parse_naive_datetimes(values: Vec<String>) -> PyResult<Vec<chrono::NaiveDateTime>> {
27 values
28 .into_iter()
29 .map(|v| {
30 chrono::NaiveDateTime::parse_from_str(&v, "%Y-%m-%d %H:%M:%S").map_err(|e| {
31 PyValueError::new_err(format!(
32 "invalid datetime '{v}' (expected '%Y-%m-%d %H:%M:%S'): {e}"
33 ))
34 })
35 })
36 .collect()
37}
38
39pub fn format_naive_datetimes(values: Vec<chrono::NaiveDateTime>) -> Vec<String> {
40 values.into_iter().map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()).collect()

Calls

no outgoing calls

Tested by

no test coverage detected