| 306 | } |
| 307 | |
| 308 | void |
| 309 | clock_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 | |
| 336 | void |
| 337 | clock_print_bcd(const struct bcd_clocktime *bct, int nsdigits) |
no test coverage detected