-
Hi. When doing the following: time::serde::format_description!(
date_time_format,
PrimitiveDateTime,
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]"
); Is it possible to access to format to be used for turning a date back into string? const DATE_TIME_FOMRAT: &[FormatItem<'_>] = time::macros::format_description!(
"[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:3]"
);
...
let str_ts = timestamp.format(&format).unwrap().to_string(); Instead, I would prefer to do something like this: let str_ts = timestamp.format(&date_time_format::format).unwrap().to_string(); Also, slightly unrelated question, but is it possible to define "optional" time components? In the example above, I want the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
While the format description string is duplicated, the actual duplication in generated code is insignificant, as
Not currently. It is tracked in #428, where there is no update. |
Beta Was this translation helpful? Give feedback.
While the format description string is duplicated, the actual duplication in generated code is insignificant, as
const
s are effectively values that are inlined wherever they're used. With regard to exposing the value, this is doable. It's already present, just scoped to the generated module. I'll think about it some.Not currently. It is tracked in #428, where there is no update.