- Source
Methods
(inner) dateFormat(date) → {string}
Format a date into a SolarNet UTC date format.
| Name | Type | Description | 
|---|---|---|
| date | Date | the date to format | 
- Source
the formatted date value - yyyy-MM-dd
- Type:
- string
(inner) dateParse(str) → {Date}
Parse a SolarNet UTC date value.
| Name | Type | Description | 
|---|---|---|
| str | string | the string to parse -  | 
- Source
the parsed date, or null
- Type:
- Date
(inner) dateParser(str) → {Date}
Parse a UTC date string, from a variety of supported formats.
| Name | Type | Description | 
|---|---|---|
| str | String | the string to parse into a date | 
- Source
the parsed Date, or null if the date can't be parsed
- Type:
- Date
(inner) dateTimeFormat(date) → {string}
Format a date into a SolarNet UTC date/time format.
| Name | Type | Description | 
|---|---|---|
| date | Date | the date to format | 
- Source
the formatted date value - yyyy-MM-dd HH:mm
- Type:
- string
(inner) dateTimeParse(str) → {Date}
Parse a SolarNet UTC date/time.
| Name | Type | Description | 
|---|---|---|
| str | string | the string to parse - `yyyy-MM-dd HH:mm | 
- Source
the parsed date, or null
- Type:
- Date
(inner) dateTimeUrlFormat(date) → {string}
Format a date into a SolarNet URL UTC date/time format.
| Name | Type | Description | 
|---|---|---|
| date | Date | the date to format | 
- Source
the formatted date value - yyyy-MM-dd'T'HH:mm
- Type:
- string
(inner) dateTimeUrlParse(str) → {Date}
Parse a SolarNet URL UTC date/time value.
| Name | Type | Description | 
|---|---|---|
| str | string | the string to parse -  | 
- Source
the parsed date, or null
- Type:
- Date
(inner) displayScaleForValue(value) → {number}
Get an appropriate multiplier value for scaling a given value to a more display-friendly form.
This will return values suitable for passing to module:format~displayUnitsForScale.
| Name | Type | Description | 
|---|---|---|
| value | number | the value to get a display scale factor for, for example the maximum value in a range of values | 
- Source
the display scale factor
- Type:
- number
(inner) displayUnitsForScale(baseUnit, scale) → {string}
Get an appropriate display unit for a given base unit and scale factor.
Use this method to render scaled data value units. Typically you would first call module:module:format~displayScaleForValue, passing in the largest expected value in a set of data, and then pass the result to this method to generate a display unit for the base unit for that data.
For example, given a base unit of W (watts) and a maximum data value of 10000:
const fmt = import { * } from 'format/scale';
const displayScale = fmt.displayScaleForValue(10000);
const displayUnit = fmt.displayUnitForScale('W', displayScale);
The displayUnit result in that example would be kW.
| Name | Type | Description | 
|---|---|---|
| baseUnit | string | the base unit, for example  | 
| scale | number | the unit scale, which must be a recognized SI scale, such as  | 
- Source
the display unit value
- Type:
- string
(inner) iso8601Date(date, includeTimeopt) → {string}
Format a date into an ISO 8601 timestamp or date string, in the UTC time zone.
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
| date | Date | the date to format | ||
| includeTime | boolean | <optional> | false | 
 | 
- Source
the formatted date string
- Type:
- string
(inner) localDateTimeUrlFormat(date) → {string}
Format a date into a SolarNet URL local date/time format.
| Name | Type | Description | 
|---|---|---|
| date | Date | the date to format | 
- Source
the formatted date value - yyyy-MM-dd'T'HH:mm
- Type:
- string
(inner) seasonForDate(date) → {number}
Get a UTC season constant for a date. Seasons are groups of 3 months, e.g. Spring, Summer, Autumn, Winter.
The returned value will be a number between 0 and 3, where:
- (Mar, Apr, May) = 0
- (Jun, Jul, Aug) = 1
- (Sep, Oct, Nov) = 2
- (Dec, Jan, Feb) = 3
| Name | Type | Description | 
|---|---|---|
| date | Date | | either a date to get the season for, or a number representing the UTC month of a date | 
- Source
a season constant number, from 0 - 3
- Type:
- number
(inner) timestampFormat(date) → {string}
Format a date into a SolarNet UTC timestamp format.
| Name | Type | Description | 
|---|---|---|
| date | Date | the date to format | 
- Source
the formatted date value - yyyy-MM-dd HH:mm:ss.SSS'Z'
- Type:
- string
(inner) timestampParse(str) → {Date}
Parse a SolarNet UTC timestamp value.
| Name | Type | Description | 
|---|---|---|
| str | string | the string to parse - `yyyy-MM-dd HH:mm:ss.SSS'Z' | 
- Source
the parsed date, or null
- Type:
- Date