Date class
An RFC 3339 full-date (YYYY-MM-DD): a calendar day, with no time and no
timezone.
Deliberately a plain year/month/day value class rather than a wrapper around
DateTime. A DateTime is a specific instant, so any date backed by one
leaks a timezone bug that no normalization can close: stored as UTC midnight
it reads as the previous day under .toLocal() in negative-offset zones;
stored as local midnight it breaks the wire round-trip and hits the DST
"no midnight" gap. A date is not an instant, so this type does not hold one.
Converting to a DateTime therefore forces you to choose the timezone
explicitly — toUtcDateTime / toLocalDateTime, no silent default.
Dart core has no date-only type (see https://github.com/dart-lang/sdk/issues/49426); if it gains one, this becomes an alias for it.
- Implemented types
- Annotations
-
- @immutable
Constructors
Properties
Methods
-
compareTo(
Date other) → int -
Zero-padded toJson compares lexicographically == chronologically.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → String -
toLocalDateTime(
) → DateTime - This date at midnight in the local timezone.
-
toString(
) → String -
A string representation of this object.
override
-
toUtcDateTime(
) → DateTime - This date at midnight UTC. You must pick the timezone; no silent default.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
maybeFromJson(
String? json) → Date? - Nullable convenience for optional fields.