production
This commit is contained in:
@@ -83,6 +83,46 @@ String clockOf(DateTime t) {
|
||||
return '$hour12:$minute ${t.hour < 12 ? 'AM' : 'PM'}';
|
||||
}
|
||||
|
||||
/// `Today`, `Yesterday`, or `17 Aug` — which day a record belongs to.
|
||||
///
|
||||
/// A clock alone is ambiguous the moment a rider opens a record that is not
|
||||
/// today's, and Activity's own rule bans the all-caps date band that used to
|
||||
/// answer it. This is the same fact as a caption on the record itself, where it
|
||||
/// costs one line rather than a header per group.
|
||||
String dayLabel(DateTime t, {DateTime? now}) {
|
||||
final today = now ?? DateTime.now();
|
||||
final day = DateTime(t.year, t.month, t.day);
|
||||
final ref = DateTime(today.year, today.month, today.day);
|
||||
final diff = ref.difference(day).inDays;
|
||||
if (diff == 0) return 'Today';
|
||||
if (diff == 1) return 'Yesterday';
|
||||
const months = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec',
|
||||
];
|
||||
return '${t.day} ${months[t.month - 1]}';
|
||||
}
|
||||
|
||||
/// `2:05` — the same clock as [clockOf] with the meridiem dropped.
|
||||
///
|
||||
/// For a strip of four times on one line, where the `AM`/`PM` is both the
|
||||
/// widest part of the string and the part a rider can infer from the three
|
||||
/// beside it.
|
||||
String shortClockOf(DateTime t) {
|
||||
final hour12 = t.hour % 12 == 0 ? 12 : t.hour % 12;
|
||||
return '$hour12:${t.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
/// A duration at a glance: `6m`, `1h 12m`.
|
||||
///
|
||||
/// Seconds are never shown — nothing on these screens is decided to the second,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user