From c3b79fcb3f7cfbde2583f3eafafc62adbaf70ddf Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Thu, 2 Sep 2021 01:34:32 +0200 Subject: [PATCH] today, yesterday fix --- filcnaplo/lib/utils/format.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filcnaplo/lib/utils/format.dart b/filcnaplo/lib/utils/format.dart index 72bbaa6..f4bc49b 100644 --- a/filcnaplo/lib/utils/format.dart +++ b/filcnaplo/lib/utils/format.dart @@ -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)