Skip to content

Commit f54fe2b

Browse files
authored
Fix as_date: Avoid narrowing conversion, addressing C4244 warning (#378)
1 parent e71e0c2 commit f54fe2b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/jwt-cpp/jwt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,15 +2625,15 @@ namespace jwt {
26252625
/**
26262626
* \brief Get the contained JSON value as a date
26272627
*
2628-
* If the value is a decimal, it is rounded up to the closest integer
2628+
* If the value is a decimal, it is rounded to the closest integer
26292629
*
26302630
* \return content as date
26312631
* \throw std::bad_cast Content was not a date
26322632
*/
26332633
date as_date() const {
26342634
using std::chrono::system_clock;
2635-
if (get_type() == json::type::number) return system_clock::from_time_t(std::round(as_number()));
2636-
return system_clock::from_time_t(as_integer());
2635+
if (get_type() == json::type::number) return system_clock::from_time_t(static_cast<std::time_t>(std::round(as_number())));
2636+
return system_clock::from_time_t(static_cast<std::time_t>(as_integer()));
26372637
}
26382638

26392639
/**

0 commit comments

Comments
 (0)