Fix date formats

This commit is contained in:
dschmenk 2013-09-07 11:11:08 -07:00
parent b17af70266
commit f902991dad
3 changed files with 1116 additions and 2 deletions

BIN
src/fusea2pi Executable file

Binary file not shown.

View File

@ -173,6 +173,9 @@ static unsigned char *prodos_path(const char *uname, int *type, int *aux, unsign
} }
static unsigned int prodos_time(int year, int month, int day, int hour, int minute) static unsigned int prodos_time(int year, int month, int day, int hour, int minute)
{ {
if (year > 99)
year -= 100;
month += 1;
return (day & 0x1F) | ((month & 0x0F) << 5) | ((year & 0x7F) << 9) return (day & 0x1F) | ((month & 0x0F) << 5) | ((year & 0x7F) << 9)
| ((minute & 0x3F) << 16) | ((hour & 0x1F) << 24); | ((minute & 0x3F) << 16) | ((hour & 0x1F) << 24);
} }
@ -182,11 +185,12 @@ static time_t unix_time(unsigned int ptime)
memset(&tm, 0, sizeof(struct tm)); memset(&tm, 0, sizeof(struct tm));
tm.tm_mday = ptime & 0x1F; tm.tm_mday = ptime & 0x1F;
tm.tm_mon = (ptime >> 5) & 0x0F; tm.tm_mon = (ptime >> 5) & 0x0F;
tm.tm_year = (ptime >> 9) & 0x7F + 1900; tm.tm_year = (ptime >> 9) & 0x7F;
tm.tm_min = (ptime >> 16) & 0x3F; tm.tm_min = (ptime >> 16) & 0x3F;
tm.tm_hour = (ptime >> 24) & 0x1F; tm.tm_hour = (ptime >> 24) & 0x1F;
if (tm.tm_year < 1980) if (tm.tm_year < 80)
tm.tm_year += 100; tm.tm_year += 100;
tm.tm_mon -= 1;
return mktime(&tm); return mktime(&tm);
} }
struct stat *unix_stat(struct stat *stbuf, int storage, int access, int blocks, int size, int mod, int create) struct stat *unix_stat(struct stat *stbuf, int storage, int access, int blocks, int size, int mod, int create)

1110
src/fusea2pi.c~ Executable file

File diff suppressed because it is too large Load Diff