MCPcopy Create free account
hub / github.com/elastic/devfiler / mk_time_axis

Function mk_time_axis

src/ui/timeaxis.rs:70–84  ·  view source on GitHub ↗
(axis: Axis)

Source from the content-addressed store, hash-verified

68}
69
70pub fn mk_time_axis(axis: Axis) -> AxisHints<'static> {
71 AxisHints::new(axis).formatter(|x, _| {
72 let t = ts2chrono(x.value as i64);
73
74 let has_seconds = t.second() != 0;
75 let has_minutes = t.minute() != 0;
76 let has_hours = t.hour() != 0;
77
78 if !has_hours && !has_minutes && !has_seconds {
79 t.date_naive().to_string()
80 } else {
81 format!("{}:{:02}", t.hour(), t.minute())
82 }
83 })
84}
85
86pub fn ts2chrono(ts: i64) -> chrono::DateTime<chrono::Utc> {
87 chrono::DateTime::from_timestamp(ts.max(0), 0).unwrap()

Callers

nothing calls this directly

Calls 1

ts2chronoFunction · 0.85

Tested by

no test coverage detected