mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-30 02:54:35 +00:00
[CIFS] Fix leaps year calculation for years after 2100
Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
268f3be177
commit
438dd92626
1 changed files with 9 additions and 0 deletions
|
@ -946,6 +946,15 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
|
||||||
year = sd->Year;
|
year = sd->Year;
|
||||||
days += year * 365;
|
days += year * 365;
|
||||||
days += (year/4); /* leap year */
|
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 */
|
/* adjust for leap year where we are still before leap day */
|
||||||
days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
|
days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
|
||||||
sec += 24 * 60 * 60 * days;
|
sec += 24 * 60 * 60 * days;
|
||||||
|
|
Loading…
Add table
Reference in a new issue