getFormatTime function
Implementation
String getFormatTime(int timestamp, BuildContext context) {
final date = DateTime.fromMillisecondsSinceEpoch(timestamp);
final now = DateTime.now();
if (date.year == now.year && date.month == now.month && date.day == now.day) {
return DateFormat(S.of(context).chatHistoryDateFormatHourMine).format(date);
} else if (date.year == now.year) {
return DateFormat(
S.of(context).chatHistoryDateFormatMonthDayHourMine,
'zh',
).format(date);
} else {
return DateFormat(
S.of(context).chatHistoryDateFormatYearMonthDayHourMine,
'zh',
).format(date);
}
}