Lines Matching +full:x +full:- +full:min
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
60 error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); in sysctl_machdep_adjkerntz()
61 if (!error && req->newptr) in sysctl_machdep_adjkerntz()
77 /*--------------------------------------------------------------------*
79 * (seconds since 1/1/1970) and yr/mo/day/hr/min/sec
86 (month_days[(m) - 1] + (m == FEBRUARY ? leapyear(y) : 0))
103 * Table to 'calculate' pow(10, 9 - nsdigits) via lookup of nsdigits.
146 * Many realtime clocks store the year as 2-digit BCD; pivot on 70 to in clock_ct_to_ts()
148 * year += 100, so interpret values between 70-199 as relative to 1900. in clock_ct_to_ts()
150 year = ct->year; in clock_ct_to_ts()
157 if (ct->mon < 1 || ct->mon > 12 || ct->day < 1 || in clock_ct_to_ts()
158 ct->day > days_in_month(year, ct->mon) || in clock_ct_to_ts()
159 ct->hour > 23 || ct->min > 59 || ct->sec > 59 || year < 1970 || in clock_ct_to_ts()
181 for (i = 1; i < ct->mon; i++) in clock_ct_to_ts()
183 days += (ct->day - 1); in clock_ct_to_ts()
185 ts->tv_sec = (((time_t)days * 24 + ct->hour) * 60 + ct->min) * 60 + in clock_ct_to_ts()
186 ct->sec; in clock_ct_to_ts()
187 ts->tv_nsec = ct->nsec; in clock_ct_to_ts()
190 printf(" = %jd.%09ld\n", (intmax_t)ts->tv_sec, ts->tv_nsec); in clock_ct_to_ts()
201 * Year may come in as 2-digit or 4-digit BCD. Split the value into in clock_bcd_to_ts()
204 bcent = bct->year >> 8; in clock_bcd_to_ts()
205 byear = bct->year & 0xff; in clock_bcd_to_ts()
209 * the BCD-to-binary conversion routines. clock_ct_to_ts() will further in clock_bcd_to_ts()
210 * validate the field ranges (such as 0 <= min <= 59) during conversion. in clock_bcd_to_ts()
212 if (!validbcd(bcent) || !validbcd(byear) || !validbcd(bct->mon) || in clock_bcd_to_ts()
213 !validbcd(bct->day) || !validbcd(bct->hour) || in clock_bcd_to_ts()
214 !validbcd(bct->min) || !validbcd(bct->sec)) { in clock_bcd_to_ts()
217 "[%04x-%02x-%02x %02x:%02x:%02x]\n", in clock_bcd_to_ts()
218 bct->year, bct->mon, bct->day, in clock_bcd_to_ts()
219 bct->hour, bct->min, bct->sec); in clock_bcd_to_ts()
224 ct.mon = FROMBCD(bct->mon); in clock_bcd_to_ts()
225 ct.day = FROMBCD(bct->day); in clock_bcd_to_ts()
226 ct.hour = FROMBCD(bct->hour); in clock_bcd_to_ts()
227 ct.min = FROMBCD(bct->min); in clock_bcd_to_ts()
228 ct.sec = FROMBCD(bct->sec); in clock_bcd_to_ts()
229 ct.dow = bct->dow; in clock_bcd_to_ts()
230 ct.nsec = bct->nsec; in clock_bcd_to_ts()
236 if (bct->ispm) in clock_bcd_to_ts()
250 secs = ts->tv_sec; in clock_ts_to_ct()
254 ct->dow = day_of_week(days); in clock_ts_to_ct()
259 days -= recent_base_days; in clock_ts_to_ct()
264 days -= days_in_year(year); in clock_ts_to_ct()
265 ct->year = year; in clock_ts_to_ct()
269 days -= days_in_month(year, i); in clock_ts_to_ct()
270 ct->mon = i; in clock_ts_to_ct()
273 ct->day = days + 1; in clock_ts_to_ct()
276 ct->hour = rsec / 3600; in clock_ts_to_ct()
278 ct->min = rsec / 60; in clock_ts_to_ct()
280 ct->sec = rsec; in clock_ts_to_ct()
281 ct->nsec = ts->tv_nsec; in clock_ts_to_ct()
284 (intmax_t)ts->tv_sec, ts->tv_nsec); in clock_ts_to_ct()
289 KASSERT(ct->year >= 0 && ct->year < 10000, in clock_ts_to_ct()
290 ("year %d isn't a 4 digit year", ct->year)); in clock_ts_to_ct()
291 KASSERT(ct->mon >= 1 && ct->mon <= 12, in clock_ts_to_ct()
292 ("month %d not in 1-12", ct->mon)); in clock_ts_to_ct()
293 KASSERT(ct->day >= 1 && ct->day <= 31, in clock_ts_to_ct()
294 ("day %d not in 1-31", ct->day)); in clock_ts_to_ct()
295 KASSERT(ct->hour >= 0 && ct->hour <= 23, in clock_ts_to_ct()
296 ("hour %d not in 0-23", ct->hour)); in clock_ts_to_ct()
297 KASSERT(ct->min >= 0 && ct->min <= 59, in clock_ts_to_ct()
298 ("minute %d not in 0-59", ct->min)); in clock_ts_to_ct()
300 KASSERT(ct->sec >= 0 && ct->sec <= 60, in clock_ts_to_ct()
301 ("seconds %d not in 0-60", ct->sec)); in clock_ts_to_ct()
312 bct->ispm = false; in clock_ts_to_bcd()
315 ct.hour -= 12; in clock_ts_to_bcd()
316 bct->ispm = true; in clock_ts_to_bcd()
322 bct->year = TOBCD(ct.year % 100) | (TOBCD(ct.year / 100) << 8); in clock_ts_to_bcd()
323 bct->mon = TOBCD(ct.mon); in clock_ts_to_bcd()
324 bct->day = TOBCD(ct.day); in clock_ts_to_bcd()
325 bct->hour = TOBCD(ct.hour); in clock_ts_to_bcd()
326 bct->min = TOBCD(ct.min); in clock_ts_to_bcd()
327 bct->sec = TOBCD(ct.sec); in clock_ts_to_bcd()
328 bct->dow = ct.dow; in clock_ts_to_bcd()
329 bct->nsec = ct.nsec; in clock_ts_to_bcd()
339 printf("%4.4x-%2.2x-%2.2x %2.2x:%2.2x:%2.2x.%*.*ld", in clock_print_bcd()
340 bct->year, bct->mon, bct->day, in clock_print_bcd()
341 bct->hour, bct->min, bct->sec, in clock_print_bcd()
342 nsdigits, nsdigits, bct->nsec / nsdivisors[nsdigits]); in clock_print_bcd()
344 printf("%4.4x-%2.2x-%2.2x %2.2x:%2.2x:%2.2x", in clock_print_bcd()
345 bct->year, bct->mon, bct->day, in clock_print_bcd()
346 bct->hour, bct->min, bct->sec); in clock_print_bcd()
357 printf("%04d-%02d-%02d %02d:%02d:%02d.%*.*ld", in clock_print_ct()
358 ct->year, ct->mon, ct->day, in clock_print_ct()
359 ct->hour, ct->min, ct->sec, in clock_print_ct()
360 nsdigits, nsdigits, ct->nsec / nsdivisors[nsdigits]); in clock_print_ct()
362 printf("%04d-%02d-%02d %02d:%02d:%02d", in clock_print_ct()
363 ct->year, ct->mon, ct->day, in clock_print_ct()
364 ct->hour, ct->min, ct->sec); in clock_print_ct()