TimeAxis class final Getting started

Converts between calendar dates and times in days since an origin, which is the time unit the components' defaults are chosen for.

A calendar day always counts as exactly one, including the 23- and 25-hour days at a daylight-saving change, and the time of day is read off the wall clock. So a reading at 07:00 every morning lands on whole numbers of days all year round, and dateAt inverts timeOf exactly. Subtracting two DateTimes and dividing by 24 hours does neither across a change of clocks.

Dates are compared in the time zone of origin: local if it is local, UTC if it is UTC.

final axis = TimeAxis.days(readings.first.date);
final data = [for (final r in readings) axis.observation(r.date, r.kg)];
final grid = [for (var d = 0; d <= axis.timeOf(today); d++) d.toDouble()];
final posterior = model.smooth(data, grid: grid);
final firstDay = axis.dateAt(posterior.times.first);

Constructors

TimeAxis.days(DateTime origin)
Days since origin, which is time zero.

Properties

hashCode → int
The hash code for this object.
no setteroverride
origin → DateTime
The date and time that is time zero.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

dateAt(double time) → DateTime
The date and wall-clock time time days after origin; the inverse of timeOf.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observation(DateTime date, double value, {double relativeVariance = 1}) → Observation
An Observation of value at date.
timeOf(DateTime date) → double
Days from origin to date, counting calendar days as one each and adding the difference in wall-clock time of day.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override