Classes

BitmaskEnum
ComparableEnum
Configuration
DatumStreamMetadataRegistry
Enum
KeyedEnum
MultiMap
PropMap

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:

  1. date - assumed to be a Date object already and returned directly
  2. localDate - a string in yyyy-MM-dd form, optionally with a string localTime property for an associated time in HH:mm form, treated as UTC
  3. created - a string in yyyy-MM-dd HH:mm:ss.SSS'Z' or yyyy-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.

Parameters:
NameTypeDescription
dObject

the datum object to extract a date from

Returns:

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.

Parameters:
NameTypeDescription
dataArray | String

the datum stream data array (or JSON array value) to create a datum instance

metamodule:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry

a metadata instance or metadata registry to decode with

Returns:

the datum, or null if one cannot be created

Type: 
module:domain~AggregateDatum | module:domain~Datum

(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 : numDays
  • Day : numMonths
  • Month : 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});
Parameters:
NameTypeAttributesDescription
aggregatemodule:domain~Aggregation

the aggregate level to get a query range for

aggregateTimeCountnumber | module:util~DateRangeConfiguration

the number of aggregate time units to use

endDateDate<optional>

the ending date; if not provided the current date will be used

Returns:

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.

Parameters:
NameTypeDescription
dataArray | String

the datum stream data array (or JSON array value) to create a datum instance

metamodule:domain~DatumStreamMetadata | module:util~DatumStreamMetadataRegistry

a metadata instance or metadata registry to decode with

Returns:

the datum, or null if one cannot be created

Type: 
module:domain~StreamAggregateDatum | module:domain~StreamDatum

Type Definitions

DateRange

An object that defines a date range.

Type:
  • Object
Properties
NameTypeDescription
startDate

the starting date

endDate

the ending date

timeUnitmodule:domain~Aggregation

the time unit used by the date range

timeCountnumber

the number of time units in the date range

aggregatemodule:domain~Aggregation

the aggregate to query with

DateRangeConfiguration

An object that defines levels of date range configuration.

Type:
  • Object
Properties
NameTypeAttributesDescription
numHoursnumber<optional>

the number of hours to use

numDaysnumber<optional>

the number of days to use

numMonthsnumber<optional>

the number of months to use

numYearsnumber<optional>

the number of years to use