Offset class sealed
An offset is the time difference between a timezone and UTC.
A positive offset indicates a timezone ahead of UTC, while a negative offset indicates a timezone behind UTC.
An Offset is immutable. It is always in the range, -18:00
to +18:00
, inclusive.
Offsets are stored to second precision. This allows all offsets in the TZ database to be represented. It can cause issues in rare or fictional cases when used with other timezone data sources.
See:
- OffsetTime to represent times with fixed offsets.
- ZonedDateTime to represent date-times with timezones.
Constructors
- Offset([int hour = 0, int minute = 0, int second = 0])
-
Creates an Offset.
factory
- Offset.fromMicroseconds(int microseconds)
-
Creates an Offset from the total
microseconds
, truncated to the nearest second.factory - Offset.fromSeconds(int seconds)
-
Creates an Offset from the total
seconds
.factory - Offset.now()
-
Creates an Offset that represents the current offset.
factory
- Offset.parse(String offset)
-
Creates an Offset from the formatted
offset
.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hashValue → int
-
This object's hash.
no setteroverride
- inMicroseconds → int
-
This offset in microseconds.
no setter
- inMilliseconds → int
-
This offset in milliseconds.
no setter
- inSeconds → int
-
This offset in seconds.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
Duration duration) → Offset -
Returns a copy of this with the
duration
added. -
compareTo(
Offset other) → int -
Compares this object to another object.
override
-
difference(
Offset other) → Duration -
Returns the difference between this and
other
. -
minus(
{int hours = 0, int minutes = 0, int seconds = 0}) → Offset - Returns a copy of this with the sum of the units of time subtracted.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
plus(
{int hours = 0, int minutes = 0, int seconds = 0}) → Offset - Returns a copy of this with the sum of the units of time added.
-
subtract(
Duration duration) → Offset -
Returns a copy of this with the
duration
subtracted. -
toDuration(
) → Duration - Convert this to a Duration.
-
toString(
) → String -
Returns an offset ID. The ID is a minor variation of an ISO-8601 formatted offset string.
override
-
tryMinus(
{int hours = 0, int minutes = 0, int seconds = 0}) → Offset? - Returns a copy of this with the sum of the units of time subtracted.
-
tryPlus(
{int hours = 0, int minutes = 0, int seconds = 0}) → Offset? - Returns a copy of this with the sum of the units of time added.
Operators
-
operator <(
Offset other) → bool -
Returns true if this is less than
other
.inherited -
operator <=(
Offset other) → bool -
Returns true if this is equal to or less than
other
.inherited -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Offset other) → bool -
Returns true if this is more than
other
.inherited -
operator >=(
Offset other) → bool -
Returns
true
if this is equal to or more thanother
.inherited