today, yesterday fix

This commit is contained in:
unknown 2021-09-02 01:34:32 +02:00
parent 3cf57ac6d4
commit c3b79fcb3f
No known key found for this signature in database
GPG Key ID: 1D070E0B09CFB257

View File

@ -37,11 +37,11 @@ extension DateFormatUtils on DateTime {
if (timeOnly) return DateFormat("HH:mm").format(this);
DateTime now = DateTime.now();
if (this.difference(now).inDays == 0) {
if (now.year == this.year && now.month == this.month && now.day == this.day) {
if (this.hour == 0 && this.minute == 0 && this.second == 0) return "Today".i18n;
return DateFormat("HH:mm").format(this);
}
if (this.difference(now).inDays == 1) return "Yesterday".i18n;
if (now.year == this.year && now.month == this.month && now.subtract(Duration(days: 1)).day == this.day) return "Yesterday".i18n;
String formatString;
if (this.year == now.year)