def _format_offset(off):
    """
    Format a timedelta into "[+-]HH:MM" format or "" for None
    """

    if off is None:
        return ''
    mins = off.days * 24 * 60 + off.seconds // 60
    sign = '-' if mins < 0 else '+'
    return sign + '%02d:%02d' % divmod(abs(mins), 60)