Commit e4a93be6 authored by Oscar Forner Martinez's avatar Oscar Forner Martinez Committed by Jan Kara

isofs: Fix bug in the way to check if the year is a leap year

Changed the whole algorithm for a call to mktime64 that takes
care of all that details.
Signed-off-by: default avatarOscar Forner Martinez <oscar.forner.martinez@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 6744e90b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* linux/fs/isofs/util.c * linux/fs/isofs/util.c
*/ */
#include <linux/time.h>
#include "isofs.h" #include "isofs.h"
/* /*
...@@ -17,9 +18,9 @@ ...@@ -17,9 +18,9 @@
int iso_date(char * p, int flag) int iso_date(char * p, int flag)
{ {
int year, month, day, hour, minute, second, tz; int year, month, day, hour, minute, second, tz;
int crtime, days, i; int crtime;
year = p[0] - 70; year = p[0];
month = p[1]; month = p[1];
day = p[2]; day = p[2];
hour = p[3]; hour = p[3];
...@@ -31,18 +32,7 @@ int iso_date(char * p, int flag) ...@@ -31,18 +32,7 @@ int iso_date(char * p, int flag)
if (year < 0) { if (year < 0) {
crtime = 0; crtime = 0;
} else { } else {
int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; crtime = mktime64(year+1900, month, day, hour, minute, second);
days = year * 365;
if (year > 2)
days += (year+1) / 4;
for (i = 1; i < month; i++)
days += monlen[i-1];
if (((year+2) % 4) == 0 && month > 2)
days++;
days += day - 1;
crtime = ((((days * 24) + hour) * 60 + minute) * 60)
+ second;
/* sign extend */ /* sign extend */
if (tz & 0x80) if (tz & 0x80)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment