diff --git a/README.md b/README.md index 3bcdadd..94a5e0f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Join the chat at https://gitter.im/HowardHinnant/date](https://badges.gitter.im/HowardHinnant/date.svg)](https://gitter.im/HowardHinnant/date?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -_**[Try it out on wandbox!](http://melpon.org/wandbox/permlink/zKiDqIUK0XwePf7Y)**_ +_**[Try it out on wandbox!](http://melpon.org/wandbox/permlink/lb6FHxHyQ1V9eCLm)**_ This is actually several separate C++11/C++14 libraries: diff --git a/date.h b/date.h index fb66308..6dfb045 100644 --- a/date.h +++ b/date.h @@ -963,8 +963,19 @@ trunc(const std::chrono::duration& d) return To{detail::trunc(std::chrono::duration_cast(d).count())}; } -// VS Update 2 provides floor, ceil, round, abs in chrono. -#if (defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918) || __cplusplus <= 201402 +#ifndef HAS_CHRONO_ROUNDING +# if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 +# define HAS_CHRONO_ROUNDING 1 +# elif defined(__cpp_lib_chrono) && __cplusplus > 201402 && __cpp_lib_chrono >= 201510 +# define HAS_CHRONO_ROUNDING 1 +# elif defined(_LIBCPP_VERSION) && __cplusplus > 201402 && _LIBCPP_VERSION >= 3800 +# define HAS_CHRONO_ROUNDING 1 +# else +# define HAS_CHRONO_ROUNDING 0 +# endif +#endif // HAS_CHRONO_ROUNDING + +#if HAS_CHRONO_ROUNDING == 0 // round down template @@ -1061,14 +1072,14 @@ ceil(const std::chrono::time_point& tp) return time_point{ceil(tp.time_since_epoch())}; } -#else // (defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918) || __cplusplus <= 201402 +#else // HAS_CHRONO_ROUNDING == 1 using std::chrono::floor; using std::chrono::ceil; using std::chrono::round; using std::chrono::abs; -#endif // (defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918) || __cplusplus <= 201402 +#endif // HAS_CHRONO_ROUNDING // trunc towards zero template