def format_time(date_obj, time_obj=None, datebox=False, dt_type=None, classes=None):
    """
    Returns formatted HTML5 elements based on given datetime object.
    By default returns a time element, but will return a .datebox if requested.

    dt_type allows passing dt_start or dt_end for hcal formatting.
    link allows passing a url to the datebox.

    classes allows sending arbitrary classnames. Useful for properly microformatting elements.

    Usage::

        {% format_time obj.pub_date %}
        {% format_time obj.start_date 'datebox' 'dtstart' %}
        {% format_time obj.end_date obj.end_time 'datebox' 'dt_end' %}
    
    """
    if not time_obj:
        time_obj = getattr(date_obj, 'time', None)

    if dt_type:
        classes = '{0} {1}'.format(classes, dt_type)
    if datebox:
        classes = '{0} {1}'.format(classes, datebox)
    return {
        'date_obj': date_obj,
        'time_obj': time_obj,
        'datebox': datebox,
        'current_year': datetime.date.today().year,
        'classes': classes
    }