def time_coord(cube):
    """
    Return the variable attached to time axis.

    Examples
    --------
    >>> import iris
    >>> url = ('http://omgsrv1.meas.ncsu.edu:8080/thredds/dodsC/'
    ...        'fmrc/us_east/US_East_Forecast_Model_Run_Collection_best.ncd')
    >>> cube = iris.load_cube(url, 'sea_water_potential_temperature')
    >>> timevar = time_coord(cube)
    >>> timevar.name()  # What is the time coordinate named?
    'time'
    >>> cube.coord_dims(timevar)  # Is it the zeroth coordinate?
    (0,)

    """

    timevars = cube.coords(axis="T", dim_coords=True)
    if not timevars:
        timevars = [
            coord for coord in cube.dim_coords if "time" in coord.name()
        ]  # noqa
        if not timevars:
            ValueError(f'Could not find "time" in {repr(cube.dim_coords)}')
    if len(timevars) != 1:
        raise ValueError("Found more than one time coordinates!")
    timevar = timevars[0]
    return timevar