mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
mod: 推荐、搜索页添加时间,修复视频搜索页无法筛选和回顶
This commit is contained in:
@@ -28,7 +28,7 @@ class Utils {
|
||||
}
|
||||
|
||||
static String numFormat(dynamic number) {
|
||||
if (number == null){
|
||||
if (number == null) {
|
||||
return '0';
|
||||
}
|
||||
if (number is String) {
|
||||
@@ -63,6 +63,26 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
// 完全相对时间显示
|
||||
static String formatTimestampToRelativeTime(timeStamp) {
|
||||
var difference = DateTime.now()
|
||||
.difference(DateTime.fromMillisecondsSinceEpoch(timeStamp * 1000));
|
||||
|
||||
if (difference.inDays > 365) {
|
||||
return '${difference.inDays ~/ 365}年前';
|
||||
} else if (difference.inDays > 30) {
|
||||
return '${difference.inDays ~/ 30}个月前';
|
||||
} else if (difference.inDays > 0) {
|
||||
return '${difference.inDays}天前';
|
||||
} else if (difference.inHours > 0) {
|
||||
return '${difference.inHours}小时前';
|
||||
} else if (difference.inMinutes > 0) {
|
||||
return '${difference.inMinutes}分钟前';
|
||||
} else {
|
||||
return '刚刚';
|
||||
}
|
||||
}
|
||||
|
||||
// 时间显示,刚刚,x分钟前
|
||||
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
||||
// 当前时间
|
||||
|
||||
Reference in New Issue
Block a user