Instant class

Represents an instant in time which is time zone aware.

A Instant object is anchored in a time zone which is specified by an offset from UTC.

Once created, neither the value nor the time zone of a Instant object may be changed.

Constructors

Instant({required int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, double timeZoneOffset = 0.0})
Creates a new Instant. The Instant will be created in the UTC time zone unless a timeZoneOffset is specified. If so, it must be in hours from UTC and it can be positive or negative.
Instant.fromDateTime(DateTime dateTime, {double? timeZoneOffset})
Creates a new Instant from the given dateTime. The Instant will be created in the time zone of the dateTime unless a timeZoneOffset is specified. If so, it will be created in the time zone corresponding to that offset from UTC.

Properties

day int
latefinal
dayOfYear int
The day of year of this Instant.
no setter
hashCode int
The hash code for this object.
no setterinherited
hour int
latefinal
isLeapYear bool
Returns true if this is in a leap year.
no setter
julianCenturies double
The number of Julian centuries of this Instant since the J2000.0 epoch.
no setter
julianDay double
The Julian day of this Instant.
no setter
minute int
latefinal
month int
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
second int
latefinal
sinceEpoch Duration
The elapsed time since the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
no setter
time Duration
The time of this Instant elapsed since the begining of the day.
no setter
timeZoneOffset double
The time zone offset in hours from UTC. It can be positive or negative.
final
year int
latefinal

Methods

add(Duration duration) Instant
Returns a new Instant instance with duration added to this.
beginingOfDay() Instant
Returns a new Instant value corresponding to the begining of the day represented by this Instant.
compareTo(Instant other) int
Compares this Instant to other, returning zero if the values are equal.
difference(Instant other) Duration
Returns a Duration with the difference when subtracting other from this.
isAfter(Instant other) bool
Returns true if this occurs after other.
isAtSameInstantAs(Instant other) bool
Returns true if this occurs at the same instant as other.
isBefore(Instant other) bool
Returns true if this occurs before other.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subtract(Duration duration) Instant
Returns a new Instant instance with duration subtracted from this.
toIso8601String() String
Returns an ISO-8601 full-precision extended format representation.
toString() String
Returns a string representation of this instance.
override
toUtc() Instant
Returns this Instant value in the UTC time zone.
toUtcDateTime() DateTime
Returns a DateTime object in the UTC time zone based on this Instant.

Operators

operator +(Duration duration) Instant
operator -(Duration duration) Instant
operator ==(Object other) bool
The equality operator.
inherited