adguard-home-manager/lib/functions/format_time.dart

29 lines
928 B
Dart
Raw Normal View History

2022-09-30 23:33:57 +02:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
String formatTimestamp(DateTime timestamp, String format) {
DateFormat f = DateFormat(format);
return f.format(timestamp);
}
2022-11-27 17:20:19 +01:00
String convertTimestampLocalTimezone(DateTime timestamp, String format) {
2022-11-27 17:18:55 +01:00
return DateFormat(format).format(timestamp.toLocal());
2022-10-02 03:58:02 +02:00
}
2022-09-30 23:33:57 +02:00
String formatTimeOfDay(TimeOfDay timestamp, String format) {
DateFormat f = DateFormat(format);
return f.format(DateTime(0, 0, 0, timestamp.hour, timestamp.minute));
2023-05-25 18:19:58 +02:00
}
String formatRemainingSeconds(int seconds) {
int h, m, s;
h = seconds ~/ 3600;
m = ((seconds - h * 3600)) ~/ 60;
s = seconds - (h * 3600) - (m * 60);
String hourLeft = h.toString().length < 2 ? "0$h" : h.toString();
String minuteLeft = m.toString().length < 2 ? "0$m" : m.toString();
String secondsLeft = s.toString().length < 2 ? "0$s" : s.toString();
return "$hourLeft:$minuteLeft:$secondsLeft";
2022-09-30 23:33:57 +02:00
}