MCPcopy Create free account
hub / github.com/ccusage/ccusage / compact_date_cell

Function compact_date_cell

rust/crates/ccusage-terminal/src/table.rs:326–339  ·  view source on GitHub ↗
(value: &str)

Source from the content-addressed store, hash-verified

324}
325
326fn compact_date_cell(value: &str) -> Option<String> {
327 let bytes = value.as_bytes();
328 if bytes.len() == 10
329 && bytes[4] == b'-'
330 && bytes[7] == b'-'
331 && bytes[..4].iter().all(u8::is_ascii_digit)
332 && bytes[5..7].iter().all(u8::is_ascii_digit)
333 && bytes[8..10].iter().all(u8::is_ascii_digit)
334 {
335 Some(format!("{}\n{}", &value[..4], &value[5..]))
336 } else {
337 None
338 }
339}
340
341fn table_line(cells: &[String], aligns: &[Align], widths: &[usize]) -> String {
342 let mut line = String::from("│");

Callers 1

compact_date_rowMethod · 0.85

Calls 2

lenMethod · 0.80
allMethod · 0.80

Tested by

no test coverage detected