nonNullableTimeStampFromJson function
Implementation
DateTime nonNullableTimeStampFromJson(Object date) {
if (date is num) {
// unix timestamp (number)
return DateTime.fromMillisecondsSinceEpoch(date.toInt() * 1000,
isUtc: true);
}
if (date is String) {
if (unixRegex.hasMatch(date)) {
// unix timestamp
return DateTime.fromMillisecondsSinceEpoch(int.parse(date) * 1000,
isUtc: true);
} else if (isoRegex.hasMatch(date)) {
// iso8601
return _iso8601Formatter.parseUtc(date);
} else if (rfcRegex.hasMatch(date)) {
// rfc822
return _rfc822Parser.parseUtc(date);
}
}
throw ArgumentError.value(date, 'date', 'Unknown date type, can not convert');
}