- Source
Classes
Methods
(inner) datumDate(d) → {Date}
Get a date associated with a "datum" style object.
This function will return a Date instance found via a property on d according to these rules:
date- assumed to be aDateobject already and returned directlylocalDate- a string inyyyy-MM-ddform, optionally with a stringlocalTimeproperty for an associated time inHH:mmform, treated as UTCcreated- a string inyyyy-MM-dd HH:mm:ss.SSS'Z'oryyyy-MM-dd'T'HH:mm:ss.SSS'Z'form
These properties are commonly returned in results from the SolarNetwork API, and thus this method is a handy way to get the dates for those objects.
Note that the localDate and localTime values are parsed as UTC. When formatted the date for display they should be formatted in UTC as well to preserve the expected value.
| Name | Type | Description |
|---|---|---|
d | Object | the datum object to extract a date from |
- Source
the extracted date, or null if no date could be extracted
- Type:
- Date
(inner) datumForStreamData(data, meta) → {module:domain~AggregateDatum|module:domain~Datum}
Get a datum instance from a stream data array.
| Name | Type | Description |
|---|---|---|
data | Array | | the datum stream data array (or JSON array value) to create a datum instance |
meta | module:domain~DatumStreamMetadata | | a metadata instance or metadata registry to decode with |
- Source
the datum, or null if one cannot be created
(inner) rollingQueryDateRange(aggregate, aggregateTimeCount, endDateopt) → {module:util~DateRange}
Get a query range appropriate for a given aggregate level.
Returns an object with start and end Date properties, using the given endDate parameter as the basis for calculating the start as an offset backwards in time based on the given aggregate level.
When aggregateTimeCount will be treated as a "next higher" aggregate level from aggregate, like this:
- <
Hour:numHours Hour:numDaysDay:numMonthsMonth:numYears
For example, you might like to render a chart using TenMinute aggregate data for the last 24 hours. You'd call this function like this:
const range = rollingQueryDateRange(Aggregates.TenMinute, 24);
// or, passing a DateRangeConfiguration
const range = rollingQueryDateRange(Aggregates.TenMinute, {numHours:24});
| Name | Type | Attributes | Description |
|---|---|---|---|
aggregate | module:domain~Aggregation | the aggregate level to get a query range for | |
aggregateTimeCount | number | | the number of aggregate time units to use | |
endDate | Date | <optional> | the ending date; if not provided the current date will be used |
- Source
the calculated date range
- Type:
- module:util~DateRange
(inner) streamDatumForData(data, meta) → {module:domain~StreamAggregateDatum|module:domain~StreamDatum}
Get a stream datum instance from a stream data array.
| Name | Type | Description |
|---|---|---|
data | Array | | the datum stream data array (or JSON array value) to create a datum instance |
meta | module:domain~DatumStreamMetadata | | a metadata instance or metadata registry to decode with |
- Source
the datum, or null if one cannot be created
Type Definitions
DateRange
An object that defines a date range.
- Object
| Name | Type | Description |
|---|---|---|
start | Date | the starting date |
end | Date | the ending date |
timeUnit | module:domain~Aggregation | the time unit used by the date range |
timeCount | number | the number of time units in the date range |
aggregate | module:domain~Aggregation | the aggregate to query with |
- Source
DateRangeConfiguration
An object that defines levels of date range configuration.
- Object
| Name | Type | Attributes | Description |
|---|---|---|---|
numHours | number | <optional> | the number of hours to use |
numDays | number | <optional> | the number of days to use |
numMonths | number | <optional> | the number of months to use |
numYears | number | <optional> | the number of years to use |
- Source