general_lib_utils_toDatetime method
DateTime?
general_lib_utils_toDatetime(
)
Implementation
DateTime? general_lib_utils_toDatetime() {
DateTime? dateTime;
try {
String data = toString();
int data_number = (num.tryParse(data) ?? 0).toInt();
if (data_number < 1) {
dateTime = DateTime.tryParse(toString());
if (dateTime != null) {
return dateTime;
}
return null;
} else {
data = "${data_number}";
}
if (data.length >= 10 || data.length <= 16) {
if (data.length == 13) {
dateTime = DateTime.fromMillisecondsSinceEpoch(data_number);
} else if (data.length == 10) {
dateTime = DateTime.fromMillisecondsSinceEpoch(data_number * 1000);
} else {
dateTime = DateTime.fromMicrosecondsSinceEpoch(data_number);
}
}
} catch (e) {}
return dateTime;
}