(input: SpanTimeInput | undefined)
| 141 | * Convert a span time input into a timestamp in seconds. |
| 142 | */ |
| 143 | export function spanTimeInputToSeconds(input: SpanTimeInput | undefined): number { |
| 144 | if (typeof input === 'number') { |
| 145 | return ensureTimestampInSeconds(input); |
| 146 | } |
| 147 | |
| 148 | if (Array.isArray(input)) { |
| 149 | // See {@link HrTime} for the array-based time format |
| 150 | return input[0] + input[1] / 1e9; |
| 151 | } |
| 152 | |
| 153 | if (input instanceof Date) { |
| 154 | return ensureTimestampInSeconds(input.getTime()); |
| 155 | } |
| 156 | |
| 157 | return timestampInSeconds(); |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Converts a timestamp to second, if it was in milliseconds, or keeps it as second. |
no test coverage detected