Lines Matching +full:compute +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
63 * Compute the Julian date from the number of days elapsed since
73 * Compute the year by starting with an approximation not smaller in jdate()
81 idt.y--; in jdate()
84 * Set r to the days left in the year and compute the month by in jdate()
88 r = ndays - r; in jdate()
89 for (idt.m = 11; month1[idt.m] > r; idt.m--) in jdate()
92 /* Compute the days left in the month */ in jdate()
93 idt.d = r - month1[idt.m]; in jdate()
109 return (-1); in ndaysj()
122 return (idt->d + month1[idt->m] + idt->y * 365 + idt->y / 4); in ndaysji()
126 * Compute the date according to the Gregorian calendar from the number of
128 * is older than 1582-10-05. This is the reverse of the function ndaysg().
133 int const *montht; /* month-table */ in gdate()
138 * Compute the year by starting with an approximation not smaller in gdate()
146 idt.y--; in gdate()
149 * Set ndays to the number of days left and compute by linear in gdate()
158 ndays = ndays - r; in gdate()
164 for (idt.m = 11; montht[idt.m] > ndays; idt.m--) in gdate()
167 idt.d = ndays - montht[idt.m]; /* the rest is the day in month */ in gdate()
179 * assumed Gregorian if younger than 1582-10-04 and Julian otherwise. This
188 return (-1); in ndaysg()
199 int nd; /* Number of days--return value */ in ndaysgi()
212 * 365d +.25d - .01d + .0025d = 365.2425d. But the tropical in ndaysgi()
214 * again one day ahead of the earth. Sigh :-) in ndaysgi()
218 if ((nd = ndaysji(idt)) == -1) in ndaysgi()
219 return (-1); in ndaysgi()
220 if (idt->y >= 1600) in ndaysgi()
221 nd = (nd - 10 - (idt->y - 1600) / 100 + (idt->y - 1600) / 400); in ndaysgi()
223 nd -= 10; in ndaysgi()
228 * Compute the week number from the number of days since March 1st year 0.
242 for (*y = dt.y + 1; nd < (fw = firstweek(*y)); (*y)--) in week()
244 return ((nd - fw) / 7 + 1); in week()
254 idt.y = y - 1; /* internal representation of y-1-1 */ in firstweek()
266 return (nd - wd + 7); in firstweek()
268 return (nd - wd); in firstweek()
275 date dmondaygi = {1997, 8, 16}; /* Internal repr. of 1997-11-17 */ in weekday()
282 /* return (nd - nmonday) modulo 7 which is the weekday */ in weekday()
283 nd = (nd - nmonday) % 7; in weekday()
299 idt->d = dt->d - 1; in date2idt()
300 if (dt->m > 2) { in date2idt()
301 idt->m = dt->m - 3; in date2idt()
302 idt->y = dt->y; in date2idt()
304 idt->m = dt->m + 9; in date2idt()
305 idt->y = dt->y - 1; in date2idt()
307 if (idt->m < 0 || idt->m > 11 || idt->y < 0) in date2idt()
318 dt->d = idt->d + 1; in idt2date()
319 if (idt->m < 10) { in idt2date()
320 dt->m = idt->m + 3; in idt2date()
321 dt->y = idt->y; in idt2date()
323 dt->m = idt->m - 9; in idt2date()
324 dt->y = idt->y + 1; in idt2date()
326 if (dt->m < 1) in idt2date()