You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Currently, the getDay method on the extension.dart requires a full 24-hour difference to display "yesterday."
For example:
On May 23rd at 11:59 PM, I send a message, and it correctly shows "Today."
However, after 12:00 AM on May 24th, the message still shows "today" instead of "Yesterday," which is confusing because the message was sent on the previous calendar day.
This behavior leads to a misleading user experience where a message sent "yesterday" continues to display as "today."
To Reproduce
Steps to reproduce the behavior:
Send a message on any day (e.g., May 23rd) close to midnight (e.g., 11:59 PM).
Check the message display after midnight (e.g., on May 24th at 12:01 AM).
Observe that the message still shows "today" instead of "yesterday."
Expected behavior
Messages sent on the previous calendar day (before midnight) should display "yesterday" after midnight, regardless of whether 24 hours have passed.
Screenshots
Below message in the image was send on Dec 02, but now is Dec 03 is still shows "today" instead of "yesterday."
Additional context
This issue might occur because the current logic uses difference(DateTime.now()).inDays, which is based on the full 24-hour difference. For a more natural user experience, the method could compare only the calendar date (ignoring time).
Suggested correction:
extension TimeDifference on DateTime {
String getDay(String chatSeparatorDatePattern) {
final now = DateTime.now();
final targetDate = DateTime(year, month, day);
final currentDate = DateTime(now.year, now.month, now.day);
final differenceInDays = currentDate.difference(targetDate).inDays;
if (differenceInDays == 0) {
return PackageStrings.today;
} else if (differenceInDays == 1) {
return PackageStrings.yesterday;
} else {
final DateFormat formatter = DateFormat(chatSeparatorDatePattern);
return formatter.format(this);
}
}
String get getDateFromDateTime {
final DateFormat formatter = DateFormat(dateFormat);
return formatter.format(this);
}
String get getTimeFromDateTime => DateFormat.Hm().format(this);
}
This modification ensures that the getDay method considers only the calendar day transition (e.g., after midnight), rather than requiring a full 24-hour difference.
The text was updated successfully, but these errors were encountered:
Describe the bug
Currently, the
getDay
method on theextension.dart
requires a full 24-hour difference to display "yesterday."For example:
This behavior leads to a misleading user experience where a message sent "yesterday" continues to display as "today."
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Messages sent on the previous calendar day (before midnight) should display "yesterday" after midnight, regardless of whether 24 hours have passed.
Screenshots
Below message in the image was send on Dec 02, but now is Dec 03 is still shows "today" instead of "yesterday."
Additional context
This issue might occur because the current logic uses difference(DateTime.now()).inDays, which is based on the full 24-hour difference. For a more natural user experience, the method could compare only the calendar date (ignoring time).
Suggested correction:
This modification ensures that the
getDay
method considers only the calendar day transition (e.g., after midnight), rather than requiring a full 24-hour difference.The text was updated successfully, but these errors were encountered: