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