diff --git a/w_common/lib/src/intl/time_intl.dart b/w_common/lib/src/intl/time_intl.dart index 06c3676..083b298 100644 --- a/w_common/lib/src/intl/time_intl.dart +++ b/w_common/lib/src/intl/time_intl.dart @@ -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'); } diff --git a/w_common/lib/time.dart b/w_common/lib/time.dart index a320b09..6de6451 100644 --- a/w_common/lib/time.dart +++ b/w_common/lib/time.dart @@ -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"