compareTimeToNowTimeToDayString function
Implementation
String compareTimeToNowTimeToDayString(DateTime compatreTime){
final diff = compareTimeToNowTime(compatreTime);
int day = diff.inDays;
if (day > 7) {
return '$day天前';
} else {
if (7 >= day && day >= 1) {
return '$day天前';
} else {
int hours = diff.inHours - day * 24;
if (24 > hours && hours >= 1) {
return '$hours小时前';
} else {
int minutes = diff.inMinutes - day * 24 * 60 - hours * 60;
if (60 > minutes && minutes >= 1) {
return '$minutes分钟前';
} else {
int seconds = diff.inSeconds - day * 24 * 60 - hours * 60 - minutes * 60;
// llog('min==${seconds}');
if (60 > seconds) {
return '$seconds秒前';
}
}
}
}
}
return diff.toString();
}