dateOnly static method

DateTime dateOnly(
  1. DateTime date
)

Returns a DateTime with the date of the original, but time set to midnight.

Implementation

static DateTime dateOnly(DateTime date) {
  return date.isUtc
      ? DateTime.utc(date.year, date.month, date.day)
      : DateTime(date.year, date.month, date.day);
}