TimeZoneAwareClock class
Clock set to SettableTimeZone, which can change at runtime.
TimeZoneAwareClock.now() will return a DateTime object whose timezone-dependent fields are set to the current date and time in the specified timezone.
Important caveats:
- It is an error to call TimeZoneAwareClock.now() before initializing SettableTimeZone. If this occurs, a severe error is logged, and the client's local time is returned.
- Do not call DateTime.millisecondsSinceEpoch or DateTime.microsecondsSinceEpoch on TimeZoneAwareClock.now(). These will return invalid data, due to the implementation strategy. Use DateTime.now() to compute timestamps instead.
- As with all
Clock
s, this is set to the client's (browser's) time, which may be incorrect or inaccurate.
- Annotations
-
- @Injectable.new()
Constructors
- TimeZoneAwareClock(SettableTimeZone timeZone)
- TimeZoneAwareClock.fixed(DateTime time)
-
Creates TimeZoneAwareClock that returns fixed
time
value.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
ago(
{int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0, int microseconds = 0}) → DateTime -
Returns the point in time that's given amount of time ago. The
amount of time is the sum of individual parts. Parts are compatible with
ones defined in Duration.
inherited
-
agoBy(
Duration duration) → DateTime -
Returns the point in time Duration amount of time ago.
inherited
-
daysAgo(
int days) → DateTime -
Return the point in time
days
ago.inherited -
daysFromNow(
int days) → DateTime -
Return the point in time
days
from now.inherited -
fromNow(
{int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0, int microseconds = 0}) → DateTime -
Returns the point in time that's given amount of time from now. The
amount of time is the sum of individual parts. Parts are compatible with
ones defined in Duration.
inherited
-
fromNowBy(
Duration duration) → DateTime -
Returns the point in time Duration amount of time from now.
inherited
-
hoursAgo(
int hours) → DateTime -
Return the point in time
hours
ago.inherited -
hoursFromNow(
int hours) → DateTime -
Return the point in time
hours
from now.inherited -
microsAgo(
int micros) → DateTime -
Return the point in time
micros
microseconds ago.inherited -
microsFromNow(
int micros) → DateTime -
Return the point in time
micros
microseconds from now.inherited -
millisAgo(
int millis) → DateTime -
Return the point in time
millis
milliseconds ago.inherited -
millisFromNow(
int millis) → DateTime -
Return the point in time
millis
milliseconds from now.inherited -
minutesAgo(
int minutes) → DateTime -
Return the point in time
minutes
ago.inherited -
minutesFromNow(
int minutes) → DateTime -
Return the point in time
minutes
from now.inherited -
monthsAgo(
int months) → DateTime -
Return the point in time
months
ago on the same date.inherited -
monthsFromNow(
int months) → DateTime -
Return the point in time
months
from now on the same date.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
now(
) → DateTime -
Returns current time.
inherited
-
secondsAgo(
int seconds) → DateTime -
Return the point in time
seconds
ago.inherited -
secondsFromNow(
int seconds) → DateTime -
Return the point in time
seconds
from now.inherited -
toString(
) → String -
A string representation of this object.
override
-
weeksAgo(
int weeks) → DateTime -
Return the point in time
weeks
ago.inherited -
weeksFromNow(
int weeks) → DateTime -
Return the point in time
weeks
from now.inherited -
yearsAgo(
int years) → DateTime -
Return the point in time
years
ago on the same date.inherited -
yearsFromNow(
int years) → DateTime -
Return the point in time
years
from now on the same date.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited