# xarray.coding.times.CFTimedeltaCoder

### *class* xarray.coding.times.CFTimedeltaCoder(time_unit=None, decode_via_units=False, decode_via_dtype=True)[[source]](https://github.com/pydata/xarray/blob/main/xarray/coding/times.py#L1476-L1563)

Coder for CF Timedelta coding.

* **Parameters:**
  * **time_unit** (`PDDatetimeUnitOptions`) – Target resolution when decoding timedeltas via units. Defaults to “ns”.
    When decoding via dtype, the resolution is specified in the dtype
    attribute, so this parameter is ignored.
  * **decode_via_units** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to decode timedeltas based on the presence of a timedelta-like
    units attribute, e.g. “seconds”. Defaults to True, but in the future
    will default to False.
  * **decode_via_dtype** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – Whether to decode timedeltas based on the presence of an np.timedelta64
    dtype attribute, e.g. “timedelta64[s]”. Defaults to True.

#### \_\_init_\_(time_unit=None, decode_via_units=False, decode_via_dtype=True)[[source]](https://github.com/pydata/xarray/blob/main/xarray/coding/times.py#L1494-L1502)

### Methods

| [`__init__`](#xarray.coding.times.CFTimedeltaCoder.__init__)([time_unit, decode_via_units, ...])   |                                                   |
|-------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `decode`(variable[, name])                                                                      | Convert a decoded variable to an encoded variable |
| `encode`(variable[, name])                                                                      | Convert an encoded variable to a decoded variable |
