Skip to content

Instantly share code, notes, and snippets.

@wrboyce
Created December 4, 2014 16:25
Show Gist options
  • Save wrboyce/6cf6b201c8675daff53d to your computer and use it in GitHub Desktop.
Save wrboyce/6cf6b201c8675daff53d to your computer and use it in GitHub Desktop.
def parse_fat_time(nhex):
if not isinstance(nhex, basestring):
nhex = '{}'.format(nhex)
if nhex.startswith('0x'):
nhex = nhex[2:]
h = ''.join([nhex[2:], nhex[:2]])
b = bin(int(h, 16))[2:]
s = b[-5:]
m = b[-11:-5]
h = b[-16:-11]
return '{}:{}:{}'.format(int(h,2), int(m,2), int(s,2)*2)
def parse_fat_date(nhex):
if not isinstance(nhex, basestring):
nhex = '{}'.format(nhex)
if nhex.startswith('0x'):
nhex = nhex[2:]
h = ''.join([nhex[2:], nhex[:2]])
b = bin(int(h, 16))[2:]
d = b[-5:]
m = b[-9:-5]
y = b[-16:-9]
return (int(d,2), int(m,2), int(y,2)+1980)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment