def get_val_at_time(dataset_id, timestamps,**kwargs):
    """
    Given a timestamp (or list of timestamps) and some timeseries data,
    return the values appropriate to the requested times.

    If the timestamp is before the start of the timeseries data, return
    None If the timestamp is after the end of the timeseries data, return
    the last value.  """
    t = []
    for time in timestamps:
        t.append(get_datetime(time))
    dataset_i = db.DBSession.query(Dataset).filter(Dataset.id==dataset_id).one()
    #for time in t:
    #    data.append(td.get_val(timestamp=time))

    data = dataset_i.get_val(timestamp=t)
    if data is not None:
        dataset = JSONObject({'data': json.dumps(data)})
    else:
        dataset = JSONObject({'data': None})

    return dataset
Given a timestamp (or list of timestamps) and some timeseries data,
    return the values appropriate to the requested times.

    If the timestamp is before the start of the timeseries data, return
    None If the timestamp is after the end of the timeseries data, return
    the last value.