Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions w_common/lib/src/intl/time_intl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ class TimeIntl {
static String yesterday(String timeOfDay) =>
Intl.message('Yesterday, $timeOfDay',
args: [timeOfDay], name: 'TimeIntl_yesterday');

static String dateAndTime(String date, String timeOfDay) =>
Intl.message('$date, $timeOfDay',
args: [date, timeOfDay], name: 'TimeIntl_dateAndTime');
}
4 changes: 2 additions & 2 deletions w_common/lib/time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ String formatTimeDifference(DateTime time, {DateTime? now}) {
// almost a week apart in the same week day.
if (deltaDays < 7 && now.weekday != time.weekday) {
// "Tuesday, XX:XXam"
return '${weekdayFormat.format(time)}, $timeOfDay';
return TimeIntl.dateAndTime(weekdayFormat.format(time), timeOfDay);
}

// Month check prevents ambiguity between dates that are
// almost a year apart in the same month.
if (deltaDays < 365 && (now.year == time.year || now.month != time.month)) {
// "January 25, XX:XXam"
return '${monthDayFormat.format(time)}, $timeOfDay';
return TimeIntl.dateAndTime(monthDayFormat.format(time), timeOfDay);
}

// "Jan 5, 2016"
Expand Down