TimeOfDay class

A value representing a time during the day, independent of the date that day might fall on or the time zone.

The time is represented by hour and minute pair. Once created, both values cannot be changed.

You can create TimeOfDay using the constructor which requires both hour and minute or using DateTime object. Hours are specified between 0 and 23, as in a 24-hour clock.

link
TimeOfDay now = TimeOfDay.now();
const TimeOfDay releaseTime = TimeOfDay(hour: 15, minute: 0); // 3:00pm
TimeOfDay roomBooked = TimeOfDay.fromDateTime(DateTime.parse('2018-10-20 16:30:04Z')); // 4:30pm

See also:

Annotations

Constructors

TimeOfDay({required int hour, required int minute})
Creates a time of day.
const
TimeOfDay.fromDateTime(DateTime time)
Creates a time of day based on the given time.
TimeOfDay.now()
Creates a time of day based on the current time.

Properties

hashCode int
The hash code for this object.
no setteroverride
hour int
The selected hour, in 24 hour time from 0..23.
final
hourOfPeriod int
Which hour of the current period (e.g., am or pm) this time is.
no setter
minute int
The selected minute.
final
period DayPeriod
Whether this time of day is before or after noon.
no setter
periodOffset int
The hour at which the current period starts.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(BuildContext context) String
Returns the localized string representation of this time of day.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replacing({int? hour, int? minute}) TimeOfDay
Returns a new TimeOfDay with the hour and/or minute replaced.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Constants

hoursPerDay → const int
The number of hours in one day, i.e. 24.
hoursPerPeriod → const int
The number of hours in one day period (see also DayPeriod), i.e. 12.
minutesPerHour → const int
The number of minutes in one hour, i.e. 60.