Time class abstract

Represents a fixed (and calendar-independent) length of time.

A Time is a fixed length of time defined by an integral number of nanoseconds. Although Times are usually used with a positive number of nanoseconds, negative Times are valid, and may occur naturally when e.g. subtracting an earlier Instant from a later one.

A Time represents a fixed length of elapsed time along the time line that occupies the same amount of time regardless of when it is applied. In contrast, Period represents a period of time in calendrical terms (years, months, days, and so on) that may vary in elapsed time when applied.

In general, use Time to represent durations applied to global types like Instant and ZonedDateTime; use Period to represent a period applied to local types like LocalDateTime.

The range of valid values of a Time is greater than the span of time supported by Time Machine - so for example, subtracting one Instant from another will always give a valid Time.

This type is immutable.

Implemented types
Annotations
  • @immutable

Constructors

Time({num days = 0, num hours = 0, num minutes = 0, num seconds = 0, num milliseconds = 0, num microseconds = 0, num nanoseconds = 0})
factory
Time.bigIntNanoseconds(BigInt bigNanoseconds)
factory
Time.duration(Duration duration)
factory

Properties

canNanosecondsBeInteger bool
no setter
hashCode int
The hash code for this object.
no setteroverride
hourOf12HourClock int
Gets the hour of the half-day of this local time, in the range 1 to 12 inclusive.
no setter
hourOfDay int
no setter
inDays int
no setter
inHours int
no setter
inMicroseconds int
no setter
inMilliseconds int
no setter
inMinutes int
no setter
inNanoseconds int
no setter
inNanosecondsAsBigInt BigInt
no setter
inSeconds int
no setter
isNegative bool
no setter
microsecondOfSecond int
no setter
millisecondOfSecond int
no setter
minuteOfHour int
no setter
nanosecondOfSecond int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secondOfMinute int
no setter
toDuration Duration
no setter
totalDays double
no setter
totalHours double
no setter
totalMicroseconds double
no setter
totalMilliseconds double
no setter
totalMinutes double
no setter
totalNanoseconds double
no setter
totalSeconds double
no setter

Methods

abs(Time other) Time
add(Time other) Time
compareTo(Time? other) int
Compares this object to another object.
override
divide(num factor) Time
equals(Time other) bool
multiply(num factor) Time
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subtract(Time other) Time
toString([String? patternText, Culture? culture]) String
A string representation of this object.
override

Operators

operator *(num factor) Time
operator +(Time other) Time
operator -(Time other) Time
operator /(num quotient) Time
operator <(Time other) bool
operator <=(Time other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(Time other) bool
operator >=(Time other) bool
operator unary-() Time

Static Properties

maxValue Time
Gets the maximum value supported by Time. (todo: is this okay for us? -- after the integer math on that division ... maybe??? maybe not???)
final
minValue Time
Gets the minimum (largest negative) value supported by Time.
final

Static Methods

max(Time x, Time y) Time
min(Time x, Time y) Time
minus(Time x, Time y) Time
plus(Time x, Time y) Time

Constants

epsilon → const Time
Gets a Time value equal to 1 nanosecond; the smallest amount by which an instant can vary.
oneDay → const Time
oneMicrosecond → const Time
oneMillisecond → const Time
oneNanosecond → const Time
oneSecond → const Time
oneWeek → const Time
zero → const Time