You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
612 B
25 lines
612 B
3 years ago
|
class ActivityFunc {
|
||
|
static String dateCheck(DateTime? date) {
|
||
|
if (date == null) {
|
||
|
return '';
|
||
|
}
|
||
|
var nowDate = DateTime.now();
|
||
|
if (date.isBefore(nowDate)) {
|
||
|
return '已结束';
|
||
|
} else {
|
||
|
var days = date.difference(nowDate).inDays;
|
||
|
if (days > 0) {
|
||
|
return '${days}天后结束';
|
||
|
} else {
|
||
|
var hours = date.difference(nowDate).inHours;
|
||
|
if (hours > 0) {
|
||
|
return '${hours}小时后结束';
|
||
|
} else {
|
||
|
var mins = date.difference(nowDate).inMinutes;
|
||
|
return '$mins分钟后结束';
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|