Lines 87-99
Link Here
|
87 |
|
87 |
|
88 |
|
88 |
|
89 |
#define FEBRUARY 2 |
89 |
#define FEBRUARY 2 |
90 |
#define days_in_year(y) (leapyear(y) ? 366 : 365) |
90 |
#define days_in_year(y) (leapyear(y) ? (time_t)366 : (time_t)365) |
91 |
#define days_in_month(y, m) \ |
91 |
#define days_in_month(y, m) \ |
92 |
(month_days[(m) - 1] + (m == FEBRUARY ? leapyear(y) : 0)) |
92 |
(month_days[(m) - 1] + (m == FEBRUARY ? leapyear(y) : 0)) |
93 |
/* Day of week. Days are counted from 1/1/1970, which was a Thursday */ |
93 |
/* Day of week. Days are counted from 1/1/1970, which was a Thursday */ |
94 |
#define day_of_week(days) (((days) + 4) % 7) |
94 |
#define day_of_week(days) (((time_t)(days) + 4) % 7) |
95 |
|
95 |
|
96 |
static const int month_days[12] = { |
96 |
static const time_t month_days[12] = { |
97 |
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
97 |
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
98 |
}; |
98 |
}; |
99 |
|
99 |
|
Lines 107-113
Link Here
|
107 |
* It is otherwise equivalent. |
107 |
* It is otherwise equivalent. |
108 |
*/ |
108 |
*/ |
109 |
static int |
109 |
static int |
110 |
leapyear(int year) |
110 |
leapyear(time_t year) |
111 |
{ |
111 |
{ |
112 |
int rv = 0; |
112 |
int rv = 0; |
113 |
|
113 |
|
Lines 133-140
Link Here
|
133 |
int |
133 |
int |
134 |
clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) |
134 |
clock_ct_to_ts(struct clocktime *ct, struct timespec *ts) |
135 |
{ |
135 |
{ |
136 |
time_t secs; |
136 |
time_t year, days, secs; |
137 |
int i, year, days; |
137 |
int i; |
138 |
|
138 |
|
139 |
year = ct->year; |
139 |
year = ct->year; |
140 |
|
140 |
|
Lines 180-188
Link Here
|
180 |
void |
180 |
void |
181 |
clock_ts_to_ct(struct timespec *ts, struct clocktime *ct) |
181 |
clock_ts_to_ct(struct timespec *ts, struct clocktime *ct) |
182 |
{ |
182 |
{ |
183 |
int i, year, days; |
183 |
int i; |
184 |
time_t rsec; /* remainder seconds */ |
184 |
time_t rsec; /* remainder seconds */ |
185 |
time_t secs; |
185 |
time_t year, days, secs; |
186 |
|
186 |
|
187 |
secs = ts->tv_sec; |
187 |
secs = ts->tv_sec; |
188 |
days = secs / SECDAY; |
188 |
days = secs / SECDAY; |