dateFromEpochSeconds function
- num? secondsSinceEpoch
Returns the date time from the given number representing the seconds since epoch.
This is useful because responses from the backend currently return date time events in seconds since epoch.
Implementation
DateTime? dateFromEpochSeconds(num? secondsSinceEpoch) {
if (secondsSinceEpoch == null) return null;
// Some events have 0 as the event time, clearly a placeholder for a null /
// missing value. Treat it as null.
if (secondsSinceEpoch == 0) return null;
return DateTime.fromMillisecondsSinceEpoch(
(secondsSinceEpoch * 1000).round(),
isUtc: false,
);
}