* fix(mobile): clamp out of range datetimes so timeline queries cannot crash * replace the per column converters with a clamping custom type * heal each table in one statement, rename the clamp type, read dates as stored * one medium test for the clamp, drop the dart side bounds, private clamp type
13 lines
312 B
Dart
13 lines
312 B
Dart
DateTime? tryFromSecondsSinceEpoch(int? secondsSinceEpoch, {bool isUtc = false}) {
|
|
if (secondsSinceEpoch == null) {
|
|
return null;
|
|
}
|
|
|
|
final milliSeconds = secondsSinceEpoch * 1000;
|
|
try {
|
|
return DateTime.fromMillisecondsSinceEpoch(milliSeconds, isUtc: isUtc);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|