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
Clocks, 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
timevalue.
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
daysago.inherited -
daysFromNow(
int days) → DateTime -
Return the point in time
daysfrom 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
hoursago.inherited -
hoursFromNow(
int hours) → DateTime -
Return the point in time
hoursfrom now.inherited -
microsAgo(
int micros) → DateTime -
Return the point in time
microsmicroseconds ago.inherited -
microsFromNow(
int micros) → DateTime -
Return the point in time
microsmicroseconds from now.inherited -
millisAgo(
int millis) → DateTime -
Return the point in time
millismilliseconds ago.inherited -
millisFromNow(
int millis) → DateTime -
Return the point in time
millismilliseconds from now.inherited -
minutesAgo(
int minutes) → DateTime -
Return the point in time
minutesago.inherited -
minutesFromNow(
int minutes) → DateTime -
Return the point in time
minutesfrom now.inherited -
monthsAgo(
int months) → DateTime -
Return the point in time
monthsago on the same date.inherited -
monthsFromNow(
int months) → DateTime -
Return the point in time
monthsfrom 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
secondsago.inherited -
secondsFromNow(
int seconds) → DateTime -
Return the point in time
secondsfrom now.inherited -
toString(
) → String -
A string representation of this object.
override
-
weeksAgo(
int weeks) → DateTime -
Return the point in time
weeksago.inherited -
weeksFromNow(
int weeks) → DateTime -
Return the point in time
weeksfrom now.inherited -
yearsAgo(
int years) → DateTime -
Return the point in time
yearsago on the same date.inherited -
yearsFromNow(
int years) → DateTime -
Return the point in time
yearsfrom now on the same date.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited