diff options
author | Steve French <sfrench@us.ibm.com> | 2006-10-10 23:49:30 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-10-10 23:49:30 -0400 |
commit | 438dd926260f11ff01fc3441ac6dd4c412d20ea4 (patch) | |
tree | a596911eeb08f23ec9b1027bb47e89582ae6edbf /fs/cifs/netmisc.c | |
parent | 268f3be177ce93791da38facc34126b5038cd851 (diff) |
[CIFS] Fix leaps year calculation for years after 2100
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/netmisc.c')
-rw-r--r-- | fs/cifs/netmisc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index 3d86b31cf2e4..32562d199552 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -946,6 +946,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time) | |||
946 | year = sd->Year; | 946 | year = sd->Year; |
947 | days += year * 365; | 947 | days += year * 365; |
948 | days += (year/4); /* leap year */ | 948 | days += (year/4); /* leap year */ |
949 | /* generalized leap year calculation is more complex, ie no leap year | ||
950 | for years/100 except for years/400, but since the maximum number for DOS | ||
951 | year is 2**7, the last year is 1980+127, which means we need only | ||
952 | consider 2 special case years, ie the years 2000 and 2100, and only | ||
953 | adjust for the lack of leap year for the year 2100, as 2000 was a | ||
954 | leap year (divisable by 400) */ | ||
955 | if(year >= 120) /* the year 2100 */ | ||
956 | days = days - 1; /* do not count leap year for the year 2100 */ | ||
957 | |||
949 | /* adjust for leap year where we are still before leap day */ | 958 | /* adjust for leap year where we are still before leap day */ |
950 | days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); | 959 | days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0); |
951 | sec += 24 * 60 * 60 * days; | 960 | sec += 24 * 60 * 60 * days; |