from datetime import datetime, timedelta


def i2dt(idat,itim):
    """Convert industry date time to datetime object

        :param idat: integer IBM industry date 0cyyddd
        :param itim: integer IBM time in 100ths of a second in day
    """
    hh=mm=ss=hs=0

    if idat > 100000:
        yy = 2000 + (idat-100000) // 1000
    else:
        yy = 2000 + idat // 1000
    tdays = timedelta(idat%1000 - 1) # day in year starting with 0

    if itim:
        hh = itim/(100*3600)
        mm = itim/(100*60) - hh*60
        ss = itim/100 - hh*60*60 - mm*60
        hs = itim%100
    return datetime(yy,1,1,hh,mm,ss,hs*10000)+tdays