datetime static method

DateTime datetime({
  1. DateTime? min,
  2. DateTime? max,
})

Returns a random DateTime between min and max. By default, min is the UTC epoch and max is the current time.

Implementation

static DateTime datetime({DateTime? min, DateTime? max}) {
  min ??= epoch;
  max ??= now;
  var sf = integer(min: 376, max: 399);
  var rand = integer(
      min: min.millisecondsSinceEpoch ~/ sf,
      max: max.millisecondsSinceEpoch ~/ sf);
  return DateTime.fromMillisecondsSinceEpoch(rand * sf);
}