kernels/linux-2.4.0/fs/fat/misc.c
/* Convert linear UNIX date to a MS-DOS time/date pair. */
Convert linear UNIX date to a MS-DOS time/date pair.
Convert linear UNIX date to a MS - DOS time / date pair .
void fat_date_unix2dos(int unix_date,unsigned short *time,
    unsigned short *date)
{
	int day,year,nl_day,month;
	unix_date -= sys_tz.tz_minuteswest*60;
	if (sys_tz.tz_dsttime) unix_date += 3600;
	*time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+
	    (((unix_date/3600) % 24) << 11);
	day = unix_date/86400-3652;
	year = day/365;
	if ((year+3)/4+365*year > day) year--;
	day -= (year+3)/4+365*year;
	if (day == 59 && !(year & 3)) {
		nl_day = day;
		month = 2;
	}
	else {
		nl_day = (year & 3) || day <= 59 ? day : day-1;
		for (month = 0; month < 12; month++)
			if (day_n[month] > nl_day) break;
	}
	*date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9);
}
void fat_date_unix2dos ( int unix_date , unsigned short * time , unsigned short * date ) { int day , year , nl_day , month ; unix_date -= sys_tz . tz_minuteswest * 60 ; if ( sys_tz . tz_dsttime ) unix_date += 3600 ; * time = ( unix_date % 60 ) / 2 + ( ( ( unix_date / 60 ) % 60 ) << 5 ) + ( ( ( unix_date / 3600 ) % 24 ) << 11 ) ; day = unix_date / 86400 - 3652 ; year = day / 365 ; if ( ( year + 3 ) / 4 + 365 * year > day ) year -- ; day -= ( year + 3 ) / 4 + 365 * year ; if ( day == 59 && ! ( year & 3 ) ) { nl_day = day ; month = 2 ; } else { nl_day = ( year & 3 ) || day <= 59 ? day : day - 1 ; for ( month = 0 ; month < 12 ; month ++ ) if ( day_n [ month ] > nl_day ) break ; } * date = nl_day - day_n [ month - 1 ] + 1 + ( month << 5 ) + ( year << 9 ) ; }
Convert linear UNIX date to a MS-DOS time/date pair.
Convert linear UNIX date to a MS - DOS time / date pair .