28 if ((y < 1000 || y > 9999) || (m < 1 || m > 12) || (d < 1 || d > 31))
30 WARN(
"date2int(): Input not in expected range.");
44 if (date > 10000000 && date < 22000000)
46 auto y =
static_cast<int>(std::floor(date / 10000.0));
47 auto m =
static_cast<int>(std::floor((date - (y * 10000)) / 100.0));
48 int d = date - (y * 10000) - (m * 100);
67 if (ddate < 10000101 || ddate > 99991231)
69 WARN(
"date2String(): Input not in expected format.");
73 auto rest(
static_cast<int>(ddate));
74 auto y =
static_cast<int>(std::floor(rest / 10000.0));
75 rest = rest % (y * 10000);
76 auto m =
static_cast<int>(std::floor(rest / 100.0));
79 WARN(
"date2String(): month not in [1:12].");
81 rest = rest % (m * 100);
85 WARN(
"date2String(): day not in [1:31].");
88 std::string day = std::to_string(d);
93 std::string month = std::to_string(m);
98 std::string s = std::to_string(y) +
"-" + month +
"-" + day;
107 str = s.substr(0, 10);
109 std::size_t sep(str.find(
'.', 0));
110 int d(atoi(str.substr(0, sep).c_str()));
111 std::size_t sep2(str.find(
'.', sep + 1));
112 int m(atoi(str.substr(sep + 1, sep2 - (sep + 1)).c_str()));
113 int y(atoi(str.substr(sep2 + 1, s.length() - (sep2 + 1)).c_str()));
119 if (s.length() == 10)
121 int d = atoi(s.substr(8, 2).c_str());
124 WARN(
"xmlDate2double(): day not in [1:31].");
126 int m = atoi(s.substr(5, 2).c_str());
129 WARN(
"xmlDate2double(): month not in [1:12].");
131 int y = atoi(s.substr(0, 4).c_str());
138 std::chrono::time_point<std::chrono::system_clock>
const& time)
140 auto const time_t = std::chrono::system_clock::to_time_t(time);
142 if (std::strftime(time_str,
sizeof(time_str),
"%Y-%m-%d %H:%M:%S%z",
143 std::localtime(&time_t)))
147 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)