MCPcopy Create free account
hub / github.com/feiyu563/PrometheusAlert / toTimestamp

Function toTimestamp

static/plugins/chart.js/Chart.js:14124–14158  ·  view source on GitHub ↗
(scale, input)

Source from the content-addressed store, hash-verified

14122}
14123
14124function toTimestamp(scale, input) {
14125 var adapter = scale._adapter;
14126 var options = scale.options.time;
14127 var parser = options.parser;
14128 var format = parser || options.format;
14129 var value = input;
14130
14131 if (typeof parser === 'function') {
14132 value = parser(value);
14133 }
14134
14135 // Only parse if its not a timestamp already
14136 if (!helpers$1.isFinite(value)) {
14137 value = typeof format === 'string'
14138 ? adapter.parse(value, format)
14139 : adapter.parse(value);
14140 }
14141
14142 if (value !== null) {
14143 return +value;
14144 }
14145
14146 // Labels are in an incompatible format and no `parser` has been provided.
14147 // The user might still use the deprecated `format` option for parsing.
14148 if (!parser && typeof format === 'function') {
14149 value = format(input);
14150
14151 // `format` could return something else than a timestamp, if so, parse it
14152 if (!helpers$1.isFinite(value)) {
14153 value = adapter.parse(value);
14154 }
14155 }
14156
14157 return value;
14158}
14159
14160function parse(scale, input) {
14161 if (helpers$1.isNullOrUndef(input)) {

Callers 2

parseFunction · 0.70
Chart.jsFile · 0.70

Calls 1

formatFunction · 0.70

Tested by

no test coverage detected