Created
December 4, 2014 16:25
-
-
Save wrboyce/6cf6b201c8675daff53d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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