| 14122 | } |
| 14123 | |
| 14124 | function 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 | |
| 14160 | function parse(scale, input) { |
| 14161 | if (helpers$1.isNullOrUndef(input)) { |