mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Start to improve messages appearance
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
/// Date utilities
|
||||
///
|
||||
@ -56,3 +57,22 @@ String dateTimeToString(DateTime time) {
|
||||
/// Format a [Duration] in the form "MM:SS"
|
||||
String formatDuration(Duration d) =>
|
||||
"${d.inMinutes < 10 ? "0" + d.inMinutes.toString() : d.inMinutes.toString()}:${d.inSeconds % 60 < 10 ? "0" + (d.inSeconds % 60).toString() : (d.inSeconds % 60).toString()}";
|
||||
|
||||
/// Compare two [DateTime] on their date
|
||||
bool isSameDate(DateTime one, DateTime other) {
|
||||
if (other == null) return false;
|
||||
return one.year == other.year &&
|
||||
one.month == other.month &&
|
||||
one.day == other.day;
|
||||
}
|
||||
|
||||
/// Format a date to make it easily shown
|
||||
String formatDisplayDate(DateTime dt, {bool date = true, bool time = true}) {
|
||||
final format = Intl(Intl.systemLocale).date();
|
||||
if (date) {
|
||||
format.add_EEEE();
|
||||
format.add_yMMMMd();
|
||||
}
|
||||
if (time) format.add_jm();
|
||||
return format.format(dt);
|
||||
}
|
Reference in New Issue
Block a user