Deleted Added
full compact
day.c (13840) day.c (15066)
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 71 unchanged lines hidden (view full) ---

80 }
81 /* Friday displays Monday's events */
82 offset = tp->tm_wday == 5 ? 3 : 1;
83 header[5].iov_base = dayname;
84 header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", tp);
85}
86
87/* convert Day[/Month][/Year] into unix time (since 1970)
1/*
2 * Copyright (c) 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 71 unchanged lines hidden (view full) ---

80 }
81 /* Friday displays Monday's events */
82 offset = tp->tm_wday == 5 ? 3 : 1;
83 header[5].iov_base = dayname;
84 header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", tp);
85}
86
87/* convert Day[/Month][/Year] into unix time (since 1970)
88 * Day: tow digits, Month: two digits, Year: digits
88 * Day: two digits, Month: two digits, Year: digits
89 */
90time_t Mktime (date)
91 char *date;
92{
93 time_t t;
94 int len;
95 struct tm tm;
96

--- 41 unchanged lines hidden (view full) ---

138 * 3-charweekday (Friday, Monday, mon.)
139 * numeric month or day (1, 2, 04)
140 *
141 * Any character may separate them, or they may not be separated. Any line,
142 * following a line that is matched, that starts with "whitespace", is shown
143 * along with the matched line.
144 */
145int
89 */
90time_t Mktime (date)
91 char *date;
92{
93 time_t t;
94 int len;
95 struct tm tm;
96

--- 41 unchanged lines hidden (view full) ---

138 * 3-charweekday (Friday, Monday, mon.)
139 * numeric month or day (1, 2, 04)
140 *
141 * Any character may separate them, or they may not be separated. Any line,
142 * following a line that is matched, that starts with "whitespace", is shown
143 * along with the matched line.
144 */
145int
146isnow(endp)
146isnow(endp, monthp, dayp, varp)
147 char *endp;
147 char *endp;
148 int *monthp;
149 int *dayp;
150 int *varp;
148{
149 int day, flags, month, v1, v2;
150
151 /*
152 * CONVENTION
153 *
154 * Month: 1-12
155 * Monthname: Jan .. Dec

--- 46 unchanged lines hidden (view full) ---

202
203 /*
204 * {Day} {Monthname} ...
205 * where Day <= 12
206 */
207 if (flags & F_ISMONTH) {
208 day = v1;
209 month = v2;
151{
152 int day, flags, month, v1, v2;
153
154 /*
155 * CONVENTION
156 *
157 * Month: 1-12
158 * Monthname: Jan .. Dec

--- 46 unchanged lines hidden (view full) ---

205
206 /*
207 * {Day} {Monthname} ...
208 * where Day <= 12
209 */
210 if (flags & F_ISMONTH) {
211 day = v1;
212 month = v2;
213 *varp = 0;
210 }
211
212 /* {Month} {Weekday,Day} ... */
213 else {
214 /* F_ISDAY set, v2 > 12, or no way to tell */
215 month = v1;
216 /* if no recognizable day, assume the first */
217 day = v2 ? v2 : 1;
214 }
215
216 /* {Month} {Weekday,Day} ... */
217 else {
218 /* F_ISDAY set, v2 > 12, or no way to tell */
219 month = v1;
220 /* if no recognizable day, assume the first */
221 day = v2 ? v2 : 1;
222 *varp = 0;
218 }
219 }
220
221 /* convert Weekday into *next* Day,
222 * e.g.: 'Sunday' -> 22
223 * 'SunayLast' -> ??
224 */
225 if (flags & F_ISDAY) {
226#if DEBUG
227 fprintf(stderr, "\nday: %d %s month %d\n", day, endp, month);
228#endif
229
223 }
224 }
225
226 /* convert Weekday into *next* Day,
227 * e.g.: 'Sunday' -> 22
228 * 'SunayLast' -> ??
229 */
230 if (flags & F_ISDAY) {
231#if DEBUG
232 fprintf(stderr, "\nday: %d %s month %d\n", day, endp, month);
233#endif
234
235 *varp = 1;
230 /* variable weekday, SundayLast, MondayFirst ... */
231 if (day < 0 || day >= 10) {
232
233 /* negative offset; last, -4 .. -1 */
234 if (day < 0) {
235 v1 = day/10 - 1; /* offset -4 ... -1 */
236 day = 10 + (day % 10); /* day 1 ... 7 */
237

--- 27 unchanged lines hidden (view full) ---

265 else
266 day = tp->tm_mday - 1;
267 }
268 }
269
270 /* wired */
271 else {
272 day = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7);
236 /* variable weekday, SundayLast, MondayFirst ... */
237 if (day < 0 || day >= 10) {
238
239 /* negative offset; last, -4 .. -1 */
240 if (day < 0) {
241 v1 = day/10 - 1; /* offset -4 ... -1 */
242 day = 10 + (day % 10); /* day 1 ... 7 */
243

--- 27 unchanged lines hidden (view full) ---

271 else
272 day = tp->tm_mday - 1;
273 }
274 }
275
276 /* wired */
277 else {
278 day = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7);
279 *varp = 1;
273 }
274 }
275
276#if DEBUG
277 fprintf(stderr, "day2: yday %d %d\n", day, tp->tm_yday);
278#endif
280 }
281 }
282
283#if DEBUG
284 fprintf(stderr, "day2: yday %d %d\n", day, tp->tm_yday);
285#endif
279 if (!(flags & F_EASTER))
286 if (!(flags & F_EASTER)) {
287 *monthp = month;
288 *dayp = day;
280 day = cumdays[month] + day;
289 day = cumdays[month] + day;
290 }
291 else {
292 for (v1 = 0; day > cumdays[v1]; v1++)
293 ;
294 *monthp = v1 - 1;
295 *dayp = day - cumdays[v1 - 1] - 1;
296 *varp = 1;
297 }
281
282 /* if today or today + offset days */
283 if (day >= tp->tm_yday - f_dayBefore &&
284 day <= tp->tm_yday + offset + f_dayAfter)
285 return (1);
286
287 /* if number of days left in this year + days to event in next year */
288 if (yrdays - tp->tm_yday + day <= offset + f_dayAfter ||

--- 82 unchanged lines hidden ---
298
299 /* if today or today + offset days */
300 if (day >= tp->tm_yday - f_dayBefore &&
301 day <= tp->tm_yday + offset + f_dayAfter)
302 return (1);
303
304 /* if number of days left in this year + days to event in next year */
305 if (yrdays - tp->tm_yday + day <= offset + f_dayAfter ||

--- 82 unchanged lines hidden ---