(units)
| 135 | |
| 136 | |
| 137 | def _is_time_like(units): |
| 138 | # test for time-like |
| 139 | # return "datetime" for datetime-like |
| 140 | # return "timedelta" for timedelta-like |
| 141 | if units is None: |
| 142 | return False |
| 143 | time_strings = [ |
| 144 | "days", |
| 145 | "hours", |
| 146 | "minutes", |
| 147 | "seconds", |
| 148 | "milliseconds", |
| 149 | "microseconds", |
| 150 | "nanoseconds", |
| 151 | ] |
| 152 | units = str(units) |
| 153 | # to prevent detecting units like `days accumulated` as time-like |
| 154 | # special casing for datetime-units and timedelta-units (GH-8269) |
| 155 | if "since" in units: |
| 156 | from xarray.coding.times import _unpack_netcdf_time_units |
| 157 | |
| 158 | try: |
| 159 | _unpack_netcdf_time_units(units) |
| 160 | except ValueError: |
| 161 | return False |
| 162 | return "datetime" |
| 163 | else: |
| 164 | return "timedelta" if any(tstr == units for tstr in time_strings) else False |
| 165 | |
| 166 | |
| 167 | def _check_fill_values(attrs, name, dtype): |
no test coverage detected
searching dependent graphs…