Skip to content

Commit 927c689

Browse files
committed
feat: show seconds in relative time display
1 parent 993939b commit 927c689

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/utils/utils.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ class Utils {
356356
return '${difference.inHours}小时前';
357357
} else if (difference.inMinutes > 0) {
358358
return '${difference.inMinutes}分钟前';
359+
} else if (difference.inSeconds > 0) {
360+
return '${difference.inSeconds}秒前';
359361
} else {
360362
return '刚刚';
361363
}
@@ -383,8 +385,10 @@ class Utils {
383385
formatType: formatType);
384386
}
385387
debugPrint('distance: $distance');
386-
if (distance <= 60) {
388+
if (distance == 0) {
387389
return '刚刚';
390+
} else if (distance < 60) {
391+
return '$distance秒前';
388392
} else if (distance <= 3600) {
389393
return '${(distance / 60).floor()}分钟前';
390394
} else if (distance <= 43200) {

0 commit comments

Comments
 (0)