isInUnixEpochRange function

bool isInUnixEpochRange(
  1. Object? value, [
  2. bool inMilliseconds = true
])

Returns true if n is in range of a Unix epoch time.

inMilliseconds If true check range in milliseconds. Default: true.

Implementation

bool isInUnixEpochRange(Object? value, [bool inMilliseconds = true]) {
  if (!isInt(value)) return false;
  var n = parseInt(value);
  if (n == null) return false;

  if (inMilliseconds) {
    return n > 946692000000 && n < 32503690800000;
  } else {
    return n > 946692000 && n < 32503690800;
  }
}