Offset class
An offset from UTC in seconds. A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America).
Offsets are always in the range of -18, +18
hours. (Note that the ends are inclusive,
so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.)
This allows all offsets within TZDB to be represented.
Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).
- Implemented types
- Annotations
-
- @immutable
Constructors
- Offset([int seconds = 0])
-
Returns an offset for the given seconds value, which may be negative.
factory
- Offset.duration(Duration duration)
-
Converts the given Duration to an offset, with fractional seconds truncated.
factory
- Offset.hours(int hours)
-
Returns an offset for the specified number of hours, which may be negative.
factory
- Offset.hoursAndMinutes(int hours, int minutes)
-
Returns an offset for the specified number of hours and minutes.
factory
- Offset.time(Time time)
-
Converts the given Time to an offset, with fractional seconds truncated.
factory
Properties
- hashCode → int
-
Returns a hash code for this instance.
no setteroverride
- inMicroseconds → int
-
Gets the number of microseconds represented by this offset, which may be negative.
no setter
- inMilliseconds → int
-
Gets the number of milliseconds represented by this offset, which may be negative.
no setter
- inNanoseconds → int
-
Gets the number of nanoseconds represented by this offset, which may be negative.
no setter
- inSeconds → int
-
Gets the number of seconds represented by this offset, which may be negative.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
Offset other) → Offset -
Returns the result of adding another Offset to this one, for a fluent alternative to
operator+()
. -
compareTo(
Offset? other) → int -
Compares the current object with another object of the same type.
override
-
equals(
Offset other) → bool - Indicates whether the current object is equal to another object of the same type.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
subtract(
Offset other) → Offset -
Returns the result of subtracting another Offset from this one, for a fluent alternative to
operator-()
. -
toDuration(
) → Duration - Converts this offset to a Duration value.
-
toString(
[String? patternText, Culture? culture]) → String -
Returns a String that represents this instance.
override
-
toTime(
) → Time - Converts this offset to a Time value.
Operators
-
operator +(
Offset other) → Offset - Implements the operator + (addition).
-
operator -(
Offset other) → Offset - Implements the operator - (subtraction).
-
operator <(
Offset other) → bool - Implements the operator < (less than).
-
operator <=(
Offset other) → bool - Implements the operator <= (less than or equal).
-
operator ==(
Object other) → bool -
Implements the operator == (equality).
override
-
operator >(
Offset other) → bool - Implements the operator > (greater than).
-
operator >=(
Offset other) → bool - Implements the operator >= (greater than or equal).
-
operator unary-(
) → Offset - Implements the unary operator - (negation).
Static Properties
Static Methods
-
max(
Offset x, Offset y) → Offset - Returns the greater offset of the given two, i.e. the one which will give a later local time when added to an instant.
-
min(
Offset x, Offset y) → Offset - Returns the lower offset of the given two, i.e. the one which will give an earlier local time when added to an instant.
-
minus(
Offset left, Offset right) → Offset -
Subtracts one Offset from another. Friendly alternative to
operator-()
. -
negate(
Offset offset) → Offset - Returns the negation of the specified offset. This is the method form of the unary minus operator.
-
plus(
Offset left, Offset right) → Offset -
Adds one Offset to another. Friendly alternative to
operator+()
.