Classes
Methods
-
<inner> datumDate(d)
-
Get a date associated with a "datum" style object.
This function will return a
Dateinstance found via a property ondaccording 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
localDateandlocalTimevalues are parsed as UTC. When formatted the date for display they should be formatted in UTC as well to preserve the expected value.Parameters:
Name Type Description dObject the datum object to extract a date from
Returns:
the extracted date, or
nullif no date could be extracted- Type
- Date
-
<inner> rollingQueryDateRange(aggregate, aggregateTimeCount [, endDate])
-
Get a query range appropriate for a given aggregate level.
Returns an object with
startandendDate properties, using the givenendDateparameter as the basis for calculating the start as an offset backwards in time based on the givenaggregatelevel.When
aggregateTimeCountwill be treated as a "next higher" aggregate level fromaggregate, like this:- <
Hour:numHours Hour:numDaysDay:numMonthsMonth:numYears
For example, you might like to render a chart using
TenMinuteaggregate 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:
Name Type Argument Description 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 Definitions
-
DateRange
-
An object that defines a date range.
Type:
- Object
Properties:
Name Type Description 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:
Name Type Argument Description 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