Umstellung auf UTC Timestamp
This commit is contained in:
1 parent
fcb3ecdbb4
commit
d5ec222efd
41 files changed
+145
-665
No files matched your search
@@ -595,7 +595,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
answer.utcUnixTime = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
answer.pos = SyncMessagePos();
|
||||
answer.pos!.time = DateTime.now().toUtc().toIso8601String();
|
||||
answer.pos!.time = currentPosition != null ? Util.toUnixMillisUtc(currentPosition.timestamp.toUtc()) : 0;
|
||||
answer.pos!.lat = currentPosition != null ? currentPosition.latitude : 0.0;
|
||||
answer.pos!.long = currentPosition != null ? currentPosition.longitude : 0.0;
|
||||
answer.pos!.acc = currentPosition != null ? currentPosition.accuracy.toInt() : 0;
|
||||
@@ -622,7 +622,7 @@ class MqttCore with ProducerMixin, ConsumerMixin {
|
||||
var trackMessage = TrackPosition();
|
||||
|
||||
if (position != null) {
|
||||
trackMessage.time = position.timestamp.toIso8601String();
|
||||
trackMessage.time = Util.toUnixMillisUtc(position.timestamp);
|
||||
trackMessage.lat = position.latitude;
|
||||
trackMessage.long = position.longitude;
|
||||
trackMessage.acc = position.accuracy.toInt();
|
||||
|
||||
+10
-3
@@ -18,6 +18,13 @@ import '../Tools/colored_safe_area.dart';
|
||||
class Util {
|
||||
static late SharedPreferences prefs;
|
||||
|
||||
// DateTime → UTC Unix timestamps
|
||||
static int toUnixMillisUtc(DateTime dt) => dt.toUtc().millisecondsSinceEpoch;
|
||||
static int nowUnixMillisUtc() => DateTime.now().toUtc().millisecondsSinceEpoch;
|
||||
// Optional: Unix seconds
|
||||
static int toUnixSecondsUtc(DateTime dt) => dt.toUtc().millisecondsSinceEpoch ~/ 1000;
|
||||
|
||||
|
||||
static init() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
@@ -427,7 +434,7 @@ Future<void> showMessageDialog(BuildContext context, String title, String messag
|
||||
|
||||
class DecimalTextInputFormatter extends TextInputFormatter {
|
||||
int maxLength;
|
||||
|
||||
|
||||
int decimalPlaces;
|
||||
|
||||
DecimalTextInputFormatter({required this.maxLength, required this.decimalPlaces});
|
||||
@@ -440,9 +447,9 @@ class DecimalTextInputFormatter extends TextInputFormatter {
|
||||
if (text != "") {
|
||||
RegExp regExp;
|
||||
if (decimalPlaces > 0) {
|
||||
regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,${' + decimalPlaces.toString() + '}');
|
||||
regExp = RegExp(r'[0-9]+[,]{0,1}[0-9]{0,${decimalPlaces}');
|
||||
} else {
|
||||
regExp = RegExp(r'[0-9]{0,' + maxLength.toString() +'}');
|
||||
regExp = RegExp(r'[0-9]{0,${maxLength}}');
|
||||
}
|
||||
filteredText = regExp.stringMatch(text);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user