static inline time_t conv_stamp(struct directory *dir) { struct tm *tmbuf; long tzone, dst; time_t accum, tmp; accum = DOS_YEAR(dir) - 1970; /* years past */ /* days passed */ accum = accum * 365L + month[DOS_MONTH(dir)-1] + DOS_DAY(dir); /* leap years */ accum += (DOS_YEAR(dir) - 1972) / 4L; /* back off 1 day if before 29 Feb */ if (!(DOS_YEAR(dir) % 4) && DOS_MONTH(dir) < 3) accum--; accum = accum * 24L + DOS_HOUR(dir); /* hours passed */ accum = accum * 60L + DOS_MINUTE(dir); /* minutes passed */ accum = accum * 60L + DOS_SEC(dir); /* seconds passed */ #ifndef OS_Minix /* correct for Time Zone */ #ifdef HAVE_GETTIMEOFDAY { struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); tzone = tz.tz_minuteswest * 60L; } #else #ifdef HAVE_TZSET { #ifndef OS_ultrix /* Ultrix defines this to be a different type */ extern long timezone; #endif tzset(); tzone = (long) timezone; } #else tzone = 0; #endif /* HAVE_TZSET */ #endif /* HAVE_GETTIMEOFDAY */ accum += tzone; #endif /* OS_Minix */ /* correct for Daylight Saving Time */ tmp = accum; tmbuf = localtime(&tmp); #ifndef OS_Minix dst = (tmbuf->tm_isdst) ? (-60L * 60L) : 0L; accum += dst; #endif return accum; }
/* * Print an MSDOS directory time stamp. */ static __inline__ void print_time(struct directory *dir) { char am_pm; int hour = DOS_HOUR(dir); if(!mtools_twenty_four_hour_clock) { am_pm = (hour >= 12) ? 'p' : 'a'; if (hour > 12) hour = hour - 12; if (hour == 0) hour = 12; } else am_pm = ' '; printf("%2d:%02d%c", hour, DOS_MINUTE(dir), am_pm); }