refactoring and checkpoint
This commit is contained in:
15
lib/core/utils/calculate_time_ago.dart
Normal file
15
lib/core/utils/calculate_time_ago.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// Fichier utilitaire pour le calcul du temps écoulé
|
||||
String calculateTimeAgo(DateTime publicationDate) {
|
||||
final now = DateTime.now();
|
||||
final difference = now.difference(publicationDate);
|
||||
|
||||
if (difference.inDays > 0) {
|
||||
return '${difference.inDays} jour${difference.inDays > 1 ? 's' : ''}';
|
||||
} else if (difference.inHours > 0) {
|
||||
return '${difference.inHours} heure${difference.inHours > 1 ? 's' : ''}';
|
||||
} else if (difference.inMinutes > 0) {
|
||||
return '${difference.inMinutes} minute${difference.inMinutes > 1 ? 's' : ''}';
|
||||
} else {
|
||||
return 'À l\'instant';
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'package:intl/intl.dart';
|
||||
|
||||
class DateFormatter {
|
||||
static String formatDate(DateTime date) {
|
||||
return DateFormat('EEEE dd MMMM yyyy', 'fr_FR').format(date);
|
||||
// Formater la date avec l'heure incluse
|
||||
return DateFormat('EEEE dd MMMM yyyy, à HH:mm', 'fr_FR').format(date);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user