def d2dms(d, delimiter=':', precision=6):
    """
    Convert decimal degrees to dd:mm:ss

    """
    inverse = ''
    if d < 0:
        inverse = '-'
    minutes, seconds = divmod(abs(d) * 3600, 60)
    degrees, minutes = divmod(minutes, 60)
    return '{0:s}{1:.0f}{4}{2:02.0f}{4}{3:0{5:d}.{6:d}f}'\
        .format(inverse, degrees, minutes, seconds, delimiter, 3 + precision,
                precision)