Time extension type
An immutable type representing a time of day without date components. All times are stored internally in UTC timezone. Any non-UTC input DateTime will be converted to UTC during construction.
Note the behavior of extension types in Dart (https://dart.dev/language/extension-types). For most intends and purposes a Time is a DateTime but the date component is not accessible. All operations are performed in UTC. See the GitHub repo for a discussion on whether this type should be a class or an extension type.
- on
Constructors
- Time.new(DateTime dateTime)
- Creates a Time from a DateTime, stripping all date components and converting to UTC. If the input DateTime is not in UTC, it will be converted automatically.
- Time.fromValues({required int hour, required int minute, int second = 0})
- Creates a Time from hour, minute, and optional second values. The resulting Time will be in UTC.
- Time.now()
-
Creates a Time representing the current time in UTC, using Zone-provided
time if available.
factory
Properties
Methods
-
compareTo(
Time other) → int - Compares two Time values in UTC, returning:
-
toIso8601String(
) → String - Converts this Time to an ISO 8601 string. The output represents the time in UTC without timezone information.