/// Human bytes with the shared binary units (`2.0 KiB`), matching the browser. String humanBytes(int size) { const unit = 1024; if (size < unit) return '$size B'; var divisor = unit; var exponent = 0; var scaled = size ~/ unit; while (scaled >= unit && exponent < 5) { divisor *= unit; exponent++; scaled ~/= unit; } return '${(size / divisor).toStringAsFixed(1)} ${'KMGTPE'[exponent]}iB'; } const _months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', ]; /// An RFC3339 timestamp as the app's one human local rendering (`20 Oct 12:00`), /// or null when blank/unparseable so the caller omits the value rather than /// printing a blank. String? formatSearchTimestamp(String value) { final text = value.trim(); if (text.isEmpty) return null; final instant = DateTime.tryParse(text); if (instant == null) return null; final local = instant.toLocal(); final hour = local.hour.toString().padLeft(2, '0'); final minute = local.minute.toString().padLeft(2, '0'); return '${local.day} ${_months[local.month - 1]} $hour:$minute'; }