diff --git a/src/modules/date/Date.cpp b/src/modules/date/Date.cpp index c7f134eaa..293f5a179 100644 --- a/src/modules/date/Date.cpp +++ b/src/modules/date/Date.cpp @@ -7,42 +7,33 @@ #include "data/WeekdayNames.h" #include "faker-cxx/Helper.h" #include "faker-cxx/Number.h" -#include "fmt/format.h" namespace faker { namespace { -std::string serializeTimePoint( - std::chrono::time_point>> - timePoint) -{ - time_t timePointTimeT = std::chrono::system_clock::to_time_t(timePoint); - - std::tm utcTime = *std::gmtime(&timePointTimeT); - - std::stringstream ss; - - ss << std::put_time(&utcTime, "%FT%TZ"); - - return ss.str(); -} - std::string betweenDate( std::chrono::time_point>> from, std::chrono::time_point>> to) { if (from > to) { - throw std::runtime_error{fmt::format("Start date is greater than end date. {{from: {}, to: {}}}", - serializeTimePoint(from), serializeTimePoint(to))}; + throw std::runtime_error{"Start date is greater than end date."}; } const auto size = std::chrono::duration_cast(to - from).count(); const auto randomDateWithinRange = from + std::chrono::seconds{Number::integer(size - 1)}; - return serializeTimePoint(std::chrono::floor(randomDateWithinRange)); + time_t timePointTimeT = std::chrono::system_clock::to_time_t(randomDateWithinRange); + + std::tm utcTime = *std::gmtime(&timePointTimeT); + + std::stringstream ss; + + ss << std::put_time(&utcTime, "%FT%TZ"); + + return ss.str(); } const auto numberOfHoursInDay = 24;