Date.today constructor

Date.today()

Creates a Date representing the current date in UTC, using Zone-provided time if available.

Note: you can mock the current Date by setting the nowKey in the Zone to a valid Now function that returns a UTC DateTime.

The resulting Date will always be in UTC.

Implementation

factory Date.today() => switch (Zone.current[nowKey]) {
      final Now now => Date(now().toUtc()),
      _ => Date(_utcNow),
    };