# xarray.coding.times.CFDatetimeCoder

### *class* xarray.coding.times.CFDatetimeCoder(use_cftime=None, time_unit='ns')[[source]](https://github.com/pydata/xarray/blob/main/xarray/coding/times.py#L1355-L1430)

Coder for CF Datetime coding.

* **Parameters:**
  * **use_cftime** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – Only relevant if encoded dates come from a standard calendar
    (e.g. “gregorian”, “proleptic_gregorian”, “standard”, or not
    specified).  If None (default), attempt to decode times to
    `np.datetime64` objects; if this is not possible, decode times to
    `cftime.datetime` objects. If True, always decode times to
    `cftime.datetime` objects, regardless of whether or not they can be
    represented using `np.datetime64` objects.  If False, always
    decode times to `np.datetime64` objects; if this is not possible
    raise an error.
    May not be supported by all the backends.
  * **time_unit** (`PDDatetimeUnitOptions`) – Target resolution when decoding dates. Defaults to “ns”.

#### \_\_init_\_(use_cftime=None, time_unit='ns')[[source]](https://github.com/pydata/xarray/blob/main/xarray/coding/times.py#L1375-L1381)

### Methods

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