Splitting time quantities, for example splitting total seconds into minutes and remaining seconds. After we run int64_t remaining = split_time(total, quotient, &next) we have total = next * quotient + remaining. Handles negative values by propagating them: If total is negative, next will be negative and remaining will always be non-negative.
| 222 | // them: If total is negative, next will be negative and remaining will |
| 223 | // always be non-negative. |
| 224 | static inline int64_t split_time(int64_t total, int64_t quotient, int64_t* next) { |
| 225 | int64_t r = total % quotient; |
| 226 | if (r < 0) { |
| 227 | *next = total / quotient - 1; |
| 228 | return r + quotient; |
| 229 | } else { |
| 230 | *next = total / quotient; |
| 231 | return r; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | static inline Status PyTime_convert_int(int64_t val, const TimeUnit::type unit, |
| 236 | int64_t* hour, int64_t* minute, int64_t* second, |
no outgoing calls
no test coverage detected