1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-09-19 22:08:49 +00:00

Show message files

This commit is contained in:
2021-03-11 00:02:41 +01:00
parent 2989e98c50
commit 6c00e0bcab
12 changed files with 498 additions and 30 deletions

View File

@@ -39,16 +39,20 @@ String diffTimeToStr(int amount) {
// Years
final years = (amount / (60 * 60 * 24 * 365)).floor();
return years == 1 ? tr("1 year") : tr("%years% years",
args: {"years": years.toString()});
return years == 1
? tr("1 year")
: tr("%years% years", args: {"years": years.toString()});
}
String diffTimeFromNowToStr(int date) {
return diffTimeToStr(time() - date);
}
/// Return properly formatted date and time
String dateTimeToString(DateTime time) {
return "${time.day}:${time.month}:${time.year} ${time.hour}:${time.minute}";
}
}
/// 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()}";

11
lib/utils/log_utils.dart Normal file
View File

@@ -0,0 +1,11 @@
/// Log utilities
///
/// @author Pierre Hubert
void logError(dynamic e, StackTrace s) {
if (e is Exception) {
print("Exception: $e\n$s");
} else {
print("Error: $e\n$s");
}
}