| 135 | // trunc (truncation toward zero) is not in std::chrono, only floor/ceil/round |
| 136 | template <typename ToDuration, typename Rep, typename Period> |
| 137 | constexpr ToDuration trunc(const std::chrono::duration<Rep, Period>& d) { |
| 138 | auto floored = std::chrono::floor<ToDuration>(d); |
| 139 | // floor rounds toward -infinity; for negative values with remainder, add 1 to get |
| 140 | // toward zero |
| 141 | if (d.count() < 0 && (d - floored).count() != 0) { |
| 142 | return floored + ToDuration{1}; |
| 143 | } |
| 144 | return floored; |
| 145 | } |
| 146 | |
| 147 | // Timezone lookup |
| 148 | inline const time_zone* locate_zone(std::string_view tz_name) { |