function [timeunix]=irig2unix(year, timelo, timehi)
   
        [JD1,julianday] =greg2julian(1970,1,1,0,0,0);
        [JD2,julianday] =greg2julian(year,1,1,0,0,0);
        numberOfDays = JD2 - JD1;       
       
                 
                 bcddays= bitand(timehi,hex2dec('0fff0000'));
        bcddays=bitshift(bcddays,-16);
         temp = bitand(bcddays, hex2dec('0f00'));
         temp=(bitshift(temp,-8))*100  ;
         temp1=bitand(bcddays, hex2dec('0f0'));
         temp1=(bitshift(temp1,-4))*10;
         bindays=temp +temp1 + bitand(bcddays, hex2dec('0f'));
        bcdhours = bitshift(bitand(timehi,hex2dec('0000ff00')),-8);
        binhours = (bitshift(bitand(bcdhours,hex2dec('0f0')),-4))*10 + bitand(bcdhours,hex2dec('0f'));
       bcdminutes = bitand(timehi,hex2dec('000000ff'));
        binminutes = (bitshift(bitand(bcdminutes,hex2dec('0f0')),-4))*10 + bitand(bcdminutes,hex2dec('0f'));
        bcdseconds = bitshift(bitand(timelo,hex2dec('ff000000')),-24);
        binseconds = (bitshift(bitand(bcdseconds, hex2dec('0f0')),-4))*10 + bitand(bcdseconds,hex2dec('0f'));
        bcdmilliseconds = bitshift(bitand(timelo,hex2dec('00fff000')),-12);
        bcdmicroseconds = bitand(timelo,hex2dec('fff'));       
       binmilliseconds = (bitshift(bitand(bcdmilliseconds,hex2dec('0f00')),-8))*100 + (bitshift(bitand(bcdmilliseconds,hex2dec('0f0')),-4))*10 + bitand(bcdmilliseconds,hex2dec('0f'));               
       binmicroseconds = (bitshift(bitand(bcdmicroseconds,hex2dec('0f00')),-8))*100 + (bitshift(bitand(bcdmicroseconds,hex2dec('0f0')),-4))*10 + bitand(bcdmicroseconds,hex2dec('0f'));
        %timeunix = (numberOfDays + bindays - 1)*86400 + binhours*3600 + binminutes*60 + binseconds + (binmilliseconds)/1000 + (binmicroseconds)/1000000;
           
        timeunix=[binminutes bcdseconds binmilliseconds binmicroseconds];
        
        
       