(timestamp)
| 79 | |
| 80 | |
| 81 | def _parse_timestamp(timestamp): |
| 82 | timestamp = ''.join(timestamp) |
| 83 | if not timestamp: |
| 84 | return None |
| 85 | if timestamp != timestamp.strip() or '_' in timestamp: |
| 86 | raise ValueError(f"Invalid timestamp: {timestamp!r}") |
| 87 | try: |
| 88 | # Simple int. |
| 89 | return Timestamp(int(timestamp), 0) |
| 90 | except ValueError: |
| 91 | try: |
| 92 | # aaaa.bbbb. Nanosecond resolution supported. |
| 93 | parts = timestamp.split('.', 1) |
| 94 | return Timestamp(int(parts[0]), int(parts[1][:9].ljust(9, "0"))) |
| 95 | except ValueError: |
| 96 | # Float. |
| 97 | ts = float(timestamp) |
| 98 | if math.isnan(ts) or math.isinf(ts): |
| 99 | raise ValueError(f"Invalid timestamp: {timestamp!r}") |
| 100 | return ts |
| 101 | |
| 102 | |
| 103 | def _is_character_escaped(s, charpos): |
no test coverage detected