* vfs.c (is_dos_date): Allow 4-digit years.
(vfs_parse_filedate): Don't limit length of the year field for DOS dates, subtract 1900 if necessary.
Этот коммит содержится в:
родитель
676c9927d6
Коммит
63faf36f15
@ -1,5 +1,9 @@
|
|||||||
2002-12-12 Pavel Roskin <proski@gnu.org>
|
2002-12-12 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* vfs.c (is_dos_date): Allow 4-digit years.
|
||||||
|
(vfs_parse_filedate): Don't limit length of the year field for
|
||||||
|
DOS dates, subtract 1900 if necessary.
|
||||||
|
|
||||||
* extfs/apt.in: Fix Y2K bug.
|
* extfs/apt.in: Fix Y2K bug.
|
||||||
* extfs/deba.in: Likewise.
|
* extfs/deba.in: Likewise.
|
||||||
* extfs/debd.in: Likewise.
|
* extfs/debd.in: Likewise.
|
||||||
|
45
vfs/vfs.c
45
vfs/vfs.c
@ -1325,17 +1325,26 @@ is_num (int idx)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return 1 for MM-DD-YY and MM-DD-YYYY */
|
||||||
static int
|
static int
|
||||||
is_dos_date (char *str)
|
is_dos_date (const char *str)
|
||||||
{
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strlen (str) == 8 && str[2] == str[5]
|
len = strlen (str);
|
||||||
&& strchr ("\\-/", (int) str[2]) != NULL)
|
if (len != 8 && len != 10)
|
||||||
return 1;
|
return 0;
|
||||||
|
|
||||||
return 0;
|
if (str[2] != str[5])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!strchr ("\\-/", (int) str[2]))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1556,24 +1565,22 @@ vfs_parse_filedate (int idx, time_t *t)
|
|||||||
where Mon is Jan-Dec, DD, MM, YY two digit day, month, year,
|
where Mon is Jan-Dec, DD, MM, YY two digit day, month, year,
|
||||||
YYYY four digit year, hh, mm, ss two digit hour, minute or second. */
|
YYYY four digit year, hh, mm, ss two digit hour, minute or second. */
|
||||||
|
|
||||||
/* Here just this special case with MM-DD-YY */
|
/* Special case with MM-DD-YY or MM-DD-YYYY */
|
||||||
if (is_dos_date (p)) {
|
if (is_dos_date (p)) {
|
||||||
p[2] = p[5] = '-';
|
p[2] = p[5] = '-';
|
||||||
|
|
||||||
if (sscanf (p, "%2d-%2d-%2d", &d[0], &d[1], &d[2]) == 3) {
|
if (sscanf (p, "%2d-%2d-%d", &d[0], &d[1], &d[2]) == 3) {
|
||||||
/* We expect to get:
|
/* Months are zero based */
|
||||||
1. MM-DD-YY
|
if (d[0] > 0)
|
||||||
2. DD-MM-YY
|
d[0]--;
|
||||||
3. YY-MM-DD
|
|
||||||
4. YY-DD-MM */
|
|
||||||
|
|
||||||
/* Hmm... maybe, next time :) */
|
if (d[2] > 1900) {
|
||||||
|
d[2] -= 1900;
|
||||||
/* At last, MM-DD-YY */
|
} else {
|
||||||
d[0]--; /* Months are zerobased */
|
/* Y2K madness */
|
||||||
/* Y2K madness */
|
if (d[2] < 70)
|
||||||
if (d[2] < 70)
|
d[2] += 100;
|
||||||
d[2] += 100;
|
}
|
||||||
|
|
||||||
tim.tm_mon = d[0];
|
tim.tm_mon = d[0];
|
||||||
tim.tm_mday = d[1];
|
tim.tm_mday = d[1];
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user