ccollect:0.6.2->0.7.0
[nslu2-linux/optware.git] / sources / unarj / unarj-2.65-time.diff
blob211ed02448c121f27d026ec6238af1720cf43716
1 --- environ.c
2 +++ environ.c
3 @@ -431,6 +431,8 @@
4 #define SUBS_DEFINED
6 #include <time.h>
7 +#include <sys/types.h>
8 +#include <utime.h>
10 #ifndef time_t
11 #define time_t long
12 @@ -558,12 +560,10 @@
13 mstonix(tstamp)
14 ulong tstamp;
16 + time_t tt;
17 + struct tm tm;
18 uint date, time;
19 - int year, month, day, hour, min, sec, daycount;
20 - long longtime;
21 - /* no. of days to beginning of month for each month */
22 - static int dsboy[12] =
23 - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
24 + int year, month, day, hour, min, sec;
26 date = (uint) ((tstamp >> 16) & 0xffff);
27 time = (uint) (tstamp & 0xffff);
28 @@ -577,18 +577,16 @@
29 min = (time >> 5) & 0x3f;
30 sec = (time & 0x1f) * 2;
32 - daycount = 365 * (year - 1970) + /* days due to whole years */
33 - (year - 1969) / 4 + /* days due to leap years */
34 - dsboy[month-1] + /* days since beginning of this year */
35 - day-1; /* days since beginning of month */
37 - if (year % 4 == 0 &&
38 - year % 400 != 0 && month >= 3) /* if this is a leap year and month */
39 - daycount++; /* is March or later, add a day */
41 - longtime = daycount * 24L * 60L * 60L +
42 - hour * 60L * 60L + min * 60 + sec;
43 - return longtime;
44 + tm.tm_sec = sec;
45 + tm.tm_min = min;
46 + tm.tm_hour = hour;
47 + tm.tm_mday = day;
48 + tm.tm_mon = month - 1;
49 + tm.tm_year = year - 1900;
50 + tm.tm_isdst = -1;
52 + tt = mktime (&tm);
53 + return tt;
56 int
57 @@ -599,20 +597,21 @@
58 uint host;
60 time_t m_time;
61 - struct utimbuf
62 - {
63 - time_t atime; /* New access time */
64 - time_t mtime; /* New modification time */
65 - } tb;
66 + struct utimbuf tb;
68 (char *) name;
69 (uint) attribute;
70 (uint) host;
72 - m_time = mstonix(tstamp) + gettz();
74 - tb.mtime = m_time; /* Set modification time */
75 - tb.atime = m_time; /* Set access time */
76 + m_time = mstonix(tstamp); /* + gettz(); */
77 + if (m_time < 0)
78 + {
79 + printf ("Invalid time, set to current time!");
80 + m_time = time ((time_t *) NULL);
81 + }
83 + tb.actime = m_time; /* Set modification time */
84 + tb.modtime = m_time; /* Set access time */
86 /* set the time stamp on the file */
87 return utime(name, &tb);