17 if ((y < 1000 || y > 9999) || (m < 1 || m > 12) || (d < 1 || d > 31))
19 WARN(
"date2int(): Input not in expected range.");
33 if (date > 10000000 && date < 22000000)
35 auto y =
static_cast<int>(std::floor(date / 10000.0));
36 auto m =
static_cast<int>(std::floor((date - (y * 10000)) / 100.0));
37 int d = date - (y * 10000) - (m * 100);
56 if (ddate < 10000101 || ddate > 99991231)
58 WARN(
"date2String(): Input not in expected format.");
62 auto rest(
static_cast<int>(ddate));
63 auto y =
static_cast<int>(std::floor(rest / 10000.0));
64 rest = rest % (y * 10000);
65 auto m =
static_cast<int>(std::floor(rest / 100.0));
68 WARN(
"date2String(): month not in [1:12].");
70 rest = rest % (m * 100);
74 WARN(
"date2String(): day not in [1:31].");
77 std::string day = std::to_string(d);
82 std::string month = std::to_string(m);
87 std::string s = std::to_string(y) +
"-" + month +
"-" + day;
96 str = s.substr(0, 10);
98 std::size_t sep(str.find(
'.', 0));
99 int d(atoi(str.substr(0, sep).c_str()));
100 std::size_t sep2(str.find(
'.', sep + 1));
101 int m(atoi(str.substr(sep + 1, sep2 - (sep + 1)).c_str()));
102 int y(atoi(str.substr(sep2 + 1, s.length() - (sep2 + 1)).c_str()));
108 if (s.length() == 10)
110 int d = atoi(s.substr(8, 2).c_str());
113 WARN(
"xmlDate2double(): day not in [1:31].");
115 int m = atoi(s.substr(5, 2).c_str());
118 WARN(
"xmlDate2double(): month not in [1:12].");
120 int y = atoi(s.substr(0, 4).c_str());
127 std::chrono::time_point<std::chrono::system_clock>
const& time)
129 auto const time_t = std::chrono::system_clock::to_time_t(time);
131 if (std::strftime(time_str,
sizeof(time_str),
"%Y-%m-%d %H:%M:%S%z",
132 std::localtime(&time_t)))
136 return "FAILED FORMATTING THE GIVEN TIME POINT.";
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
std::string date2string(double ddate)
int strDate2int(const std::string &s)
std::string formatDate(std::chrono::time_point< std::chrono::system_clock > const &time)
int date2int(int y, int m, int d)
std::string int2date(int date)
int xmlDate2int(const std::string &s)