WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Converting FileTimeCodes to YmdHms and back


#DefineFunction FileTimeCode2YmdHms(timecode)

    secs    =  (timecode & 31) * 2       ; start 0  uses 5
    minutes =  (timecode >> 5) & 63      ; start 5  uses 6
    hours   =  (timecode >> 11) & 31     ; start 11 uses 5
    days    =  (timecode >> 16) & 31     ; start 16 uses 5
    months  =  (timecode >> 21) & 15     ; start 21 uses 4
    year    =  (timecode >> 25)  + 1980  ; start 25 uses 6  1980 to 2043
    
    secs=strfixleft(secs,0,2)
    minutes=strfixleft(minutes,0,2)
    hours=strfixleft(hours,0,2)
    days=strfixleft(days,0,2)
    months=strfixleft(months,0,2)
    
    return (strcat(year,":",months,":",days,":",hours,":",minutes,":",secs))


#EndFunction

#DefineFunction  FileYmdHms2TimeCode(ymdhms)
    year    = ItemExtract(1,ymdhms,":")
    months  = ItemExtract(2,ymdhms,":")
    days    = ItemExtract(3,ymdhms,":")
    hours   = ItemExtract(4,ymdhms,":")
    minutes = ItemExtract(5,ymdhms,":")
    secs    = ItemExtract(6,ymdhms,":")
    
    Terminate(year < 1980,"TimeCode error","Year out of range (small)")
    Terminate(year > 2043,"TimeCode error","Year out of range (large)")
    
    code=0
    code = code + (secs / 2)
    code = code | (minutes << 5)
    code = code | (hours <<  11)
    code = code | (days << 16)
    code = code | (months << 21)
    code = code | ( (year-1980) << 25)
    
    return (code)
#EndFunction



fn="c:\autoexec.bat"
fc=FileTimeCode(fn)
fy=FileYmdHms(fn)

aaa=FileTimeCode2YmdHms(fc)

bbb=FileYmdHms2TimeCode(fy)

Message(fy,aaa)
Message(fc,bbb)






Article ID:   W15013
File Created: 2001:11:08:12:41:20
Last Updated: 2001:11:08:12:41:20