Skip Montanaro wrote: > Looking at the code in zipfile.py which converts a time tuple to DOS date > and time shorts (I didn't see code that went the other way), it appears that > dosdate is 7 bits for the year, 4 bits for the month and 5 bits for the day. > Dostime looks like 5 bits for the hour, 6 bits for the minute and 5 bits for > half the number of seconds. You should be able to extract those chunks into > a tm structure then call the C lib mktime() function to convert to a time in > seconds since the epoch (this is just off the top of my head): > > stm = malloc(sizeof(struct tm)); > stm->tm_sec = (dostime & 0x1f) * 2; > stm->tm_min = (dostime >> 5) & 0x3f; > stm->tm_hour = dostime >> 11); > stm->tm_mday = dosdate & 0x1f; > stm->tm_mon = (dosdate >> 5) & 0xf; > stm->tm_year = dosdate >> 9; > mtime = mktime(stm); > > Here's the layout of dosdate and dostime as I understand it from reading the > zipfile code: > > dosdate = yyyyyyymmmmddddd > dostime = hhhhhmmmmmmsssss > > where "sssss" is actually the seconds divided by 2. I'll let others check > my code. I have to dash off to a class. Thanks! How portable is this? Which header(s) should I include? Just
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4