Parse datetime `format_str` to interpret the `data`.
(format_str)
| 282 | |
| 283 | |
| 284 | def parse_datetime_format_str(format_str): |
| 285 | """Parse datetime `format_str` to interpret the `data`.""" |
| 286 | |
| 287 | # timestamp 'ts{unit}:tz' |
| 288 | timestamp_meta = re.match(r"ts([smun]):(.*)", format_str) |
| 289 | if timestamp_meta: |
| 290 | unit, tz = timestamp_meta.group(1), timestamp_meta.group(2) |
| 291 | if unit != "s": |
| 292 | # the format string describes only a first letter of the unit, so |
| 293 | # add one extra letter to convert the unit to numpy-style: |
| 294 | # 'm' -> 'ms', 'u' -> 'us', 'n' -> 'ns' |
| 295 | unit += "s" |
| 296 | |
| 297 | return unit, tz |
| 298 | |
| 299 | raise NotImplementedError(f"DateTime kind is not supported: {format_str}") |
| 300 | |
| 301 | |
| 302 | def map_date_type(data_type): |