def read_leap_seconds(tzfile='/usr/share/zoneinfo/right/UTC'):
    """
    Extract leap second information from tzdata.

    Based on example at http://stackoverflow.com/questions/19332902/            extract-historic-leap-seconds-from-tzdata

    See also 'man 5 tzfile'.
    """
    from struct import unpack, calcsize
    out = []
    with open(tzfile, 'rb') as f:
        fmt = '>4s c 15x 6l'
        (magic, format, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt, typecnt,
            charcnt) = unpack(fmt, f.read(calcsize(fmt)))
        assert magic == 'TZif'.encode('US-ASCII'), 'Not a timezone file'
        fmt = '>%(timecnt)dl %(timecnt)dB %(ttinfo)s %(charcnt)ds' % dict(
            timecnt=timecnt, ttinfo='lBB' * typecnt, charcnt=charcnt)
        f.read(calcsize(fmt))
        fmt = '>2l'
        for i in range(leapcnt):
            tleap, nleap = unpack(fmt, f.read(calcsize(fmt)))
            out.append((tleap - nleap + 1, nleap))
    return out
