Date constructor

Date(
  1. DateTime dateTime
)

Creates a Date from a DateTime, stripping all time components and converting to UTC. If the input DateTime is not in UTC, it will be converted automatically.

The resulting Date will be in UTC, regardless of the input DateTime's timezone.

Implementation

Date(DateTime dateTime)
    : _dateTime = dateTime.toUtc()._let(
            (dt) => DateTime.utc(
              dt.year,
              dt.month,
              dt.day,
            ),
          );