MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clock_ts_to_bcd

Function clock_ts_to_bcd

freebsd/kern/subr_clock.c:308–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void
309clock_ts_to_bcd(const struct timespec *ts, struct bcd_clocktime *bct, bool ampm)
310{
311 struct clocktime ct;
312
313 clock_ts_to_ct(ts, &ct);
314
315 /* If asked to handle am/pm, convert from 24hr to 12hr+pmflag. */
316 bct->ispm = false;
317 if (ampm) {
318 if (ct.hour >= 12) {
319 ct.hour -= 12;
320 bct->ispm = true;
321 }
322 if (ct.hour == 0)
323 ct.hour = 12;
324 }
325
326 bct->year = TOBCD(ct.year % 100) | (TOBCD(ct.year / 100) << 8);
327 bct->mon = TOBCD(ct.mon);
328 bct->day = TOBCD(ct.day);
329 bct->hour = TOBCD(ct.hour);
330 bct->min = TOBCD(ct.min);
331 bct->sec = TOBCD(ct.sec);
332 bct->dow = ct.dow;
333 bct->nsec = ct.nsec;
334}
335
336void
337clock_print_bcd(const struct bcd_clocktime *bct, int nsdigits)

Callers 1

atrtc_settimeFunction · 0.85

Calls 1

clock_ts_to_ctFunction · 0.85

Tested by

no test coverage detected