TimeSpan class
A time-based amount of time, such as '34.5 seconds'.
- Inheritance
- Implemented types
Constructors
- TimeSpan({int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0, int microseconds = 0})
-
Constructs a new TimeSpan instance from components.
const
- TimeSpan.between(Temporal startInclusive, Temporal endExclusive)
-
Creates a new TimeSpan instance consisting of the duration,
between
startInclusive
andendExclusive
.factory - TimeSpan.of(Duration duration)
-
Constructs a new TimeSpan instance from the given
duration
.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- inDays → int
-
The number of entire days spanned by this Duration.
no setterinherited
- inHours → int
-
The number of entire hours spanned by this Duration.
no setterinherited
- inMicroseconds → int
-
The number of whole microseconds spanned by this Duration.
no setterinherited
- inMilliseconds → int
-
The number of whole milliseconds spanned by this Duration.
no setterinherited
- inMinutes → int
-
The number of whole minutes spanned by this Duration.
no setterinherited
- inSeconds → int
-
The number of whole seconds spanned by this Duration.
no setterinherited
- isNegative → bool
-
Whether this Duration is negative.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
abs(
) → Duration -
Creates a new Duration representing the absolute length of this
Duration.
inherited
-
addTo(
Temporal temporal) → Temporal -
Returns a new instance of Temporal with this TemporalAmount
added to the given
temporal
.override -
compareTo(
Duration other) → int -
Compares this Duration to
other
, returning zero if the values are equal.inherited -
minus(
int amountToSubtract, ChronoUnit unit) → TimeSpan -
Returns a new instance of this TemporalAmount
with the given
amount
subtracted.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
plus(
int amountToAdd, ChronoUnit unit) → TimeSpan -
Returns a new instance of this TemporalAmount
with the given
amount
added.override -
subtractFrom(
Temporal temporal) → Temporal -
Returns a new instance of Temporal with this TemporalAmount
subtracted from the given
temporal
.override -
toString(
) → String -
Returns a string representation of this Duration.
inherited
Operators
-
operator *(
num factor) → Duration -
Multiplies this Duration by the given
factor
and returns the result as a new Duration object.inherited -
operator +(
Duration other) → TimeSpan -
Adds this TimeSpan and
other
and returns the sum as a new TimeSpan object.override -
operator -(
Duration other) → TimeSpan -
Subtracts
other
from this TimeSpan and returns the difference as a new TimeSpan object.override -
operator <(
Duration other) → bool -
Whether this Duration is shorter than
other
.inherited -
operator <=(
Duration other) → bool -
Whether this Duration is shorter than or equal to
other
.inherited -
operator ==(
Object other) → bool -
Whether this Duration has the same length as
other
.inherited -
operator >(
Duration other) → bool -
Whether this Duration is longer than
other
.inherited -
operator >=(
Duration other) → bool -
Whether this Duration is longer than or equal to
other
.inherited -
operator unary-(
) → TimeSpan -
Creates a new TimeSpan with the opposite direction of this TimeSpan.
override
-
operator ~/(
int quotient) → Duration -
Divides this Duration by the given
quotient
and returns the truncated result as a new Duration object.inherited