code: def sel_time(da, start_date, end_date):
      
      _assert_has_data_for_time(da, start_date, end_date)
      da[SUBSET_START_DATE_STR] = xr.DataArray(start_date)
      da[SUBSET_END_DATE_STR] = xr.DataArray(end_date)
      return da.sel(**{TIME_STR: slice(start_date, end_date)})
docs: Subset a DataArray or Dataset for a given date range.
  
      Ensures that data are present for full extent of requested range.
      Appends start and end date of the subset to the DataArray.
  
      Parameters
      ----------
      da : DataArray or Dataset
          data to subset
      start_date : np.datetime64
          start of date interval
      end_date : np.datetime64
          end of date interval
  
      Returns
      ----------
      da : DataArray or Dataset
          subsetted data
  
      Raises
      ------
      AssertionError
          if data for requested range do not exist for part or all of
          requested range