mobile bluesky app made with flutter lazurite.stormlightlabs.org/
mobile bluesky flutter
at main 22 lines 635 B view raw
1import 'package:intl/intl.dart'; 2 3class DateFormatter { 4 static String formatRelative(DateTime date) { 5 final now = DateTime.now(); 6 final difference = now.difference(date); 7 8 if (difference.inDays > 365) { 9 return DateFormat.yMMMd().format(date); 10 } else if (difference.inDays > 7) { 11 return DateFormat.MMMd().format(date); 12 } else if (difference.inDays > 0) { 13 return '${difference.inDays}d'; 14 } else if (difference.inHours > 0) { 15 return '${difference.inHours}h'; 16 } else if (difference.inMinutes > 0) { 17 return '${difference.inMinutes}m'; 18 } else { 19 return 'now'; 20 } 21 } 22}