parseUtcMillis static method
Parses the given UTC Millis into a proper DateTime class. If the
value
cannot be processed then this will return the defaultValue
or
null if there is no provided defaultValue
.
Implementation
static DateTime? parseUtcMillis(
dynamic value, [
int? defaultValue,
]) {
DateTime? result;
int? input;
if (value is int) {
input = value;
} else if (value is String || value is double) {
input = JsonClass.parseInt(value);
}
if (input == null) {
result = defaultValue == null
? null
: DateTime.fromMillisecondsSinceEpoch(
defaultValue,
isUtc: true,
);
} else {
result = DateTime.fromMillisecondsSinceEpoch(
input,
isUtc: true,
);
}
return result;
}