]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/cifs/netmisc.c
cxgb3 - Remove BUG_ON from t3b_intr_napi
[linux-2.6-omap-h63xx.git] / fs / cifs / netmisc.c
index 3d86b31cf2e4240fe5d52c9ae7fec94fdb2927ca..992e80edc720bb782cc13d5dcb1843691a240adf 100644 (file)
@@ -942,12 +942,22 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
                cERROR(1,("illegal date, month %d day: %d", month, days));
        month -= 1;
        days += total_days_of_prev_months[month];
-       days += 3653; /* account for difference in days between 1980 and 1970 */
+       days += 3652; /* account for difference in days between 1980 and 1970 */
        year = sd->Year;
        days += year * 365;
        days += (year/4); /* leap year */
+       /* generalized leap year calculation is more complex, ie no leap year
+       for years/100 except for years/400, but since the maximum number for DOS
+        year is 2**7, the last year is 1980+127, which means we need only
+        consider 2 special case years, ie the years 2000 and 2100, and only
+        adjust for the lack of leap year for the year 2100, as 2000 was a 
+        leap year (divisable by 400) */
+       if(year >= 120)  /* the year 2100 */
+               days = days - 1;  /* do not count leap year for the year 2100 */
+
        /* adjust for leap year where we are still before leap day */
-       days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
+       if(year != 120)
+               days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
        sec += 24 * 60 * 60 * days; 
 
        ts.tv_sec = sec;