17 lines
398 B
Dart
17 lines
398 B
Dart
final class DateTimeUtils {
|
|
static DateTime? toDateTime(dynamic element) {
|
|
if (element == null) {
|
|
return null;
|
|
}
|
|
String text = element.toString();
|
|
int? time = int.tryParse(text);
|
|
if (time == null) {
|
|
return null;
|
|
}
|
|
return DateTime.fromMillisecondsSinceEpoch(time);
|
|
}
|
|
|
|
static int? fromDateTime(DateTime? dt) {
|
|
return dt?.millisecondsSinceEpoch;
|
|
}
|
|
} |