Skip to content

Commit dfcf82f

Browse files
authored
fix(conversions): avoid windows min max macros
Wrap numeric_limits min/max in parentheses to prevent Windows macro expansion in timestamp checks.
1 parent e4ced11 commit dfcf82f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/time_shield/date_time_conversions.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ namespace time_shield {
525525
sec_value += detail::floor_div(ms_value, static_cast<int64_t>(MS_PER_SEC));
526526
ms_value = detail::floor_mod(ms_value, static_cast<int64_t>(MS_PER_SEC));
527527
if ((sec_value > 0 &&
528-
sec_value > (std::numeric_limits<int64_t>::max() - ms_value) / MS_PER_SEC) ||
528+
sec_value > ((std::numeric_limits<int64_t>::max)() - ms_value) / MS_PER_SEC) ||
529529
(sec_value < 0 &&
530-
sec_value < std::numeric_limits<int64_t>::min() / MS_PER_SEC)) {
530+
sec_value < (std::numeric_limits<int64_t>::min)() / MS_PER_SEC)) {
531531
return ERROR_TIMESTAMP;
532532
}
533533
return static_cast<ts_ms_t>(sec_value * MS_PER_SEC + ms_value);
@@ -551,9 +551,9 @@ namespace time_shield {
551551
sec_value += detail::floor_div(ms_value, static_cast<int64_t>(MS_PER_SEC));
552552
ms_value = detail::floor_mod(ms_value, static_cast<int64_t>(MS_PER_SEC));
553553
if ((sec_value > 0 &&
554-
sec_value > (std::numeric_limits<int64_t>::max() - ms_value) / MS_PER_SEC) ||
554+
sec_value > ((std::numeric_limits<int64_t>::max)() - ms_value) / MS_PER_SEC) ||
555555
(sec_value < 0 &&
556-
sec_value < std::numeric_limits<int64_t>::min() / MS_PER_SEC)) {
556+
sec_value < (std::numeric_limits<int64_t>::min)() / MS_PER_SEC)) {
557557
return ERROR_TIMESTAMP;
558558
}
559559
return static_cast<ts_ms_t>(sec_value * MS_PER_SEC + ms_value);

0 commit comments

Comments
 (0)