feat:增加公共组件
This commit is contained in:
@@ -11,3 +11,20 @@ String formatDateString(String date) {
|
||||
String formatTime(DateTime datetime) {
|
||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
||||
}
|
||||
|
||||
bool isToday(DateTime? date) {
|
||||
if (date == null) return false;
|
||||
|
||||
final now = DateTime.now();
|
||||
return date.year == now.year &&
|
||||
date.month == now.month &&
|
||||
date.day == now.day;
|
||||
}
|
||||
|
||||
bool isAfterToday(DateTime? date) {
|
||||
if (date == null) return false;
|
||||
|
||||
if (!isToday(date)) return false;
|
||||
|
||||
return date.isAfter(DateTime.now());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user