(axis: Axis)
| 68 | } |
| 69 | |
| 70 | pub 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 | |
| 86 | pub fn ts2chrono(ts: i64) -> chrono::DateTime<chrono::Utc> { |
| 87 | chrono::DateTime::from_timestamp(ts.max(0), 0).unwrap() |
nothing calls this directly
no test coverage detected