Round timeval value to the given precision. @param IN/OUT ts The value to round. @param dec Precision. @return False on success, true on error. */
| 1408 | @return False on success, true on error. |
| 1409 | */ |
| 1410 | bool my_timeval_round(struct timeval *tv, uint decimals) |
| 1411 | { |
| 1412 | DBUG_ASSERT(decimals <= DATETIME_MAX_DECIMALS); |
| 1413 | uint nanoseconds= msec_round_add[decimals]; |
| 1414 | tv->tv_usec+= (nanoseconds + 500) / 1000; |
| 1415 | if (tv->tv_usec < 1000000) |
| 1416 | goto ret; |
| 1417 | |
| 1418 | tv->tv_usec= 0; |
| 1419 | tv->tv_sec++; |
| 1420 | if (!IS_TIME_T_VALID_FOR_TIMESTAMP(tv->tv_sec)) |
| 1421 | { |
| 1422 | tv->tv_sec= TIMESTAMP_MAX_VALUE; |
| 1423 | return true; |
| 1424 | } |
| 1425 | |
| 1426 | ret: |
| 1427 | my_timeval_trunc(tv, decimals); |
| 1428 | return false; |
| 1429 | } |
| 1430 | |
| 1431 | |
| 1432 | /** |
nothing calls this directly
no test coverage detected