31 #ifndef HELPER_DATETIME_HPP_ 32 #define HELPER_DATETIME_HPP_ 36 #include "../Main/Exception.hpp" 38 #include "../_extern/date/include/date/date.h" 56 #include <string_view> 66 using std::string_view_literals::operator
""sv;
91 "st"sv,
"nd"sv,
"rd"sv,
"th"sv
101 "-ый"sv,
"-го"sv,
"-му"sv,
"-ми"sv,
"-й"sv,
"-я"sv,
"-е"sv,
"-м"sv,
"-х"sv
106 "-а"sv,
"-е"sv,
"-і"sv,
"-я"sv,
"-є"sv
240 std::string& dateTime,
241 const std::string& customFormat
244 std::string& dateTime,
245 const std::string& customFormat,
246 const std::string& locale
251 [[nodiscard]] std::string
getYearAndWeek(
const std::string& date);
252 void reduceDate(std::string& date, std::uint8_t resolution);
261 [[nodiscard]] std::string
now();
273 [[nodiscard]]
bool isISODateInRange(std::string_view isoDate, std::string_view rangeFrom, std::string_view rangeTo);
279 [[nodiscard]] std::vector<std::string>
getDateGap(
280 const std::string&
first,
281 const std::string&
second,
282 std::uint8_t resolution
284 [[nodiscard]] std::vector<std::string>
getWeekGap(
const std::string& first,
const std::string& second);
285 [[nodiscard]] std::vector<std::string>
getDayGap(
const std::string& first,
const std::string& second);
286 [[nodiscard]] std::vector<std::string>
getMonthGap(
const std::string& first,
const std::string& second);
287 [[nodiscard]] std::vector<std::string>
getYearGap(
const std::string& first,
const std::string& second);
293 template<std::
size_t N>
295 const std::array<std::string_view, N>& suffixes,
296 std::string& strInOut
298 template<std::
size_t N>
300 std::string_view currentLocale,
301 std::string_view localePrefix,
302 const std::array<std::string_view, N>& suffixes,
303 std::string& strInOut
306 void fixRussianMonths(std::string_view locale, std::string& strInOut, std::string& formatInOut);
307 void fixUkrainianMonths(std::string_view locale, std::string& strInOut, std::string& formatInOut);
308 void fixFinnishMonths(std::string_view locale, std::string_view format, std::string& strInOut);
312 std::string& formatString,
313 const std::string& dateTimeString,
399 std::string& dateTime,
400 const std::string& customFormat
403 if(dateTime.empty()) {
407 if(customFormat.empty()) {
409 "DateTime::convertCustomDateTimeToSQLTimeStamp():" 410 " No custom format specified" 426 std::int64_t offset{};
432 catch(
const std::exception& e) {
434 "DateTime::convertCustomDateTimeToSQLTimeStamp(): Invalid date/time format - " 436 +
" [expected: UNIX, UNIX+N or UNIX-N where N is a valid number]" 442 std::time_t unixTime{};
445 if(dateTime.find(
'.') != std::string::npos) {
447 float f{std::stof(dateTime)};
449 unixTime =
static_cast<std::time_t
>(std::lround(f));
452 unixTime =
static_cast<std::time_t
>(std::stol(dateTime));
455 catch(
const std::exception& e) {
457 "Could not convert '" 459 +
"' [expected format: '" 469 dateTime = date::format(
471 std::chrono::system_clock::from_time_t(unixTime)
478 std::istringstream in(dateTime);
479 date::sys_seconds tp;
481 in >> date::parse(customFormat, tp);
484 dateTime = date::format(sqlTimeStamp, tp);
488 std::string formatString{customFormat};
496 std::istringstream inStringStream(dateTime);
498 inStringStream.imbue(std::locale(std::setlocale(LC_ALL,
nullptr)));
500 inStringStream >> std::get_time(&cTime, formatString.c_str());
502 if(inStringStream.fail()) {
504 "Could not convert '" 506 +
"' [expected format: '" 516 std::array<char, sqlTimeStampLength + 1> out{};
523 dateTime = std::string(out.data(), len);
527 "Could not convert '" 529 +
"' [expected format: '" 537 fixYear(dateTime, customFormat);
572 std::string& dateTime,
573 const std::string& customFormat,
574 const std::string& locale
577 if(dateTime.empty()) {
581 if(customFormat.empty()) {
583 "DateTime::convertCustomDateTimeToSQLTimeStamp():" 584 " No custom format specified" 598 std::string formatString{customFormat};
609 std::istringstream in(dateTime);
610 date::sys_seconds tp;
613 in.imbue(std::locale(locale));
615 catch(
const std::runtime_error& e) {
619 in >> date::parse(formatString, tp);
622 dateTime = date::format(sqlTimeStamp, tp);
633 std::istringstream inStringStream(dateTime);
635 inStringStream.imbue(std::locale(locale));
637 inStringStream >> std::get_time(&cTime, formatString.c_str());
639 if(inStringStream.fail()) {
641 "Could not convert '" 643 +
"' [expected format: '" 653 std::array<char, sqlTimeStampLength + 1> out{};
660 dateTime = std::string(out.data(), len);
664 "Could not convert '" 666 +
"' [expected format: '" 675 fixYear(dateTime, customFormat);
714 if(timeStamp.empty()) {
718 std::istringstream in(timeStamp);
719 date::sys_seconds tp;
721 in >> date::parse(sqlTimeStamp, tp);
725 "Could not convert SQL timestamp '" 731 timeStamp = date::format(
"%Y%m%d%H%M%S", tp);
776 std::istringstream in(date);
779 in >> date::parse(
"%F", tp);
783 "Could not convert date '" 789 return date::format(
"%G-#%V", tp);
807 inline void reduceDate(std::string& date, std::uint8_t resolution) {
813 throw Exception(
"Invalid length of date " + date);
841 throw Exception(
"Invalid date resolution: " + std::to_string(resolution));
860 auto rest{microseconds};
890 result += std::to_string(days) +
"d ";
894 result += std::to_string(hours) +
"h ";
898 result += std::to_string(minutes) +
"min ";
902 result += std::to_string(seconds) +
"s ";
905 if(milliseconds > 0) {
906 result += std::to_string(milliseconds) +
"ms ";
910 result += std::to_string(rest) +
"μs ";
934 auto rest{milliseconds};
957 result += std::to_string(days) +
"d ";
961 result += std::to_string(hours) +
"h ";
965 result += std::to_string(minutes) +
"min ";
969 result += std::to_string(seconds) +
"s ";
973 result += std::to_string(rest) +
"ms ";
1004 const auto hours{
static_cast<std::uint8_t
>(rest /
secondsPerHour)};
1014 result += std::to_string(days) +
"d ";
1018 result += std::to_string(hours) +
"h ";
1022 result += std::to_string(minutes) +
"min ";
1026 result += std::to_string(rest) +
"s ";
1029 if(result.empty()) {
1046 return date::format(
1048 date::floor<std::chrono::seconds>(
1072 std::istringstream in(isoDate);
1075 in >> date::parse(
"%F", tp);
1106 std::string_view isoDate,
1107 std::string_view rangeFrom,
1108 std::string_view rangeTo
1155 const std::string& first,
1156 const std::string& second,
1157 std::uint8_t resolution
1160 switch(resolution) {
1178 throw Exception(
"Invalid date resolution: " + std::to_string(resolution));
1207 inline std::vector<std::string>
getWeekGap(
const std::string& first,
const std::string& second) {
1209 if(first > second) {
1214 std::istringstream inFirst(first +
"-1");
1215 date::sys_days tpFirst;
1217 inFirst >> date::parse(
"%G-#%V-%u", tpFirst);
1219 if(!
bool(inFirst)) {
1220 throw Exception(
"Invalid week: '" + first +
"' (expected: YYYY-#WW)");
1223 std::istringstream inSecond(second +
"-1");
1224 date::sys_days tpSecond;
1226 inSecond >> date::parse(
"%G-#%V-%u", tpSecond);
1228 if(!
bool(inSecond)) {
1229 throw Exception(
"Invalid week: '" + second +
"' (expected: YYYY-#WW)");
1233 std::vector<std::string> result;
1234 const auto distance{
static_cast<std::size_t
>((tpSecond - tpFirst).count()) / 7};
1237 result.reserve(distance - 1);
1241 for(std::size_t week{1}; week < distance; ++week) {
1244 result.emplace_back(
getYearAndWeek(date::format(
"%F", tpFirst)));
1271 inline std::vector<std::string>
getDayGap(
const std::string& first,
const std::string& second) {
1273 if(first > second) {
1278 std::istringstream inFirst(first);
1279 date::sys_days tpFirst;
1281 inFirst >> date::parse(
"%F", tpFirst);
1283 if(!
bool(inFirst)) {
1284 throw Exception(
"Invalid date: '" + first +
"' (expected: YYYY-MM-DD)");
1287 std::istringstream inSecond(second);
1288 date::sys_days tpSecond;
1290 inSecond >> date::parse(
"%F", tpSecond);
1292 if(!
bool(inSecond)) {
1293 throw Exception(
"Invalid date: '" + second +
"' (expected: YYYY-MM-DD)");
1297 std::vector<std::string> result;
1298 const auto distance{
static_cast<std::size_t
>((tpSecond - tpFirst).count())};
1301 result.reserve(distance - 1);
1305 for(std::size_t day{1}; day < distance; ++day) {
1306 tpFirst += date::days{1};
1308 result.emplace_back(date::format(
"%F", tpFirst));
1335 inline std::vector<std::string>
getMonthGap(
const std::string& first,
const std::string& second) {
1337 if(first > second) {
1342 std::istringstream inFirst(first);
1343 date::year_month tpFirst;
1345 inFirst >> date::parse(
"%Y-%m", tpFirst);
1347 if(!
bool(inFirst)) {
1348 throw Exception(
"Invalid month: '" + first +
"' (expected: YYYY-MM)");
1351 std::istringstream inSecond(second);
1352 date::year_month tpSecond;
1354 inSecond >> date::parse(
"%Y-%m", tpSecond);
1356 if(!
bool(inSecond)) {
1357 throw Exception(
"Invalid month: '" + second +
"' (expected: YYYY-MM)");
1361 std::vector<std::string> result;
1362 const auto distance{
static_cast<std::size_t
>((tpSecond - tpFirst).count())};
1365 result.reserve(distance - 1);
1369 for(std::size_t month{1}; month < distance; ++month) {
1370 tpFirst += date::months{1};
1372 result.emplace_back(date::format(
"%Y-%m", tpFirst));
1399 inline std::vector<std::string>
getYearGap(
const std::string& first,
const std::string& second) {
1401 if(first > second) {
1406 std::istringstream inFirst(first);
1409 inFirst >> date::parse(
"%Y", tpFirst);
1411 if(!
bool(inFirst)) {
1412 throw Exception(
"Invalid year: '" + first +
"' (expected: YYYY)");
1415 std::istringstream inSecond(second);
1418 inSecond >> date::parse(
"%Y", tpSecond);
1420 if(!
bool(inSecond)) {
1421 throw Exception(
"Invalid year: '" + second +
"' (expected: YYYY)");
1425 std::vector<std::string> result;
1426 const auto distance{
static_cast<std::size_t
>((tpSecond - tpFirst).count())};
1429 result.reserve(distance - 1);
1434 tpFirst += date::years{1};
1436 result.emplace_back(date::format(
"%Y", tpFirst));
1456 const std::array<std::string_view, N>& suffixes,
1457 std::string& strInOut
1461 while(pos < strInOut.length()) {
1462 auto next{std::string::npos};
1465 for(
const auto& suffix : suffixes) {
1466 const auto search{strInOut.find(suffix, pos)};
1470 len = suffix.length();
1476 if(pos == std::string::npos) {
1481 if(std::isdigit(strInOut.at(pos - 1)) != 0) {
1482 const auto end{pos + len};
1485 end == strInOut.length()
1486 || std::isspace(strInOut.at(end)) != 0
1487 || std::ispunct(strInOut.at(end)) != 0
1490 strInOut.erase(pos, len);
1528 std::string_view currentLocale,
1529 std::string_view localePrefix,
1530 const std::array<std::string_view, N>& suffixes,
1531 std::string& strInOut
1533 if(currentLocale.length() >= localePrefix.length()) {
1534 std::string prefix(currentLocale, 0, localePrefix.length());
1541 return std::tolower(c);
1545 if(prefix == localePrefix) {
1546 removeOrdinals<N>(suffixes, strInOut);
1572 return std::tolower(c);
1602 inline void fixRussianMonths(std::string_view locale, std::string& strInOut, std::string& formatInOut) {
1611 return std::tolower(c);
1616 std::string oldString;
1619 formatInOut.find(
"%B") != std::string::npos
1623 oldString = strInOut;
1742 if(bigB && strInOut != oldString) {
1752 formatInOut.find(
"%b") != std::string::npos
1753 || formatInOut.find(
"%B") != std::string::npos
1763 return std::tolower(c);
1790 inline void fixUkrainianMonths(std::string_view locale, std::string& strInOut, std::string& formatInOut) {
1799 return std::tolower(c);
1805 formatInOut.find(
"%B") != std::string::npos
1807 std::string oldString;
1810 oldString = strInOut;
1934 if(bigB && strInOut != oldString) {
1959 inline void fixFinnishMonths(std::string_view locale, std::string_view format, std::string& strInOut) {
1961 format.find(
"%b") != std::string::npos
1971 return std::tolower(c);
2031 while(pos < dateTimeString.length()) {
2032 pos = dateTimeString.find_first_of(
"123456789", pos);
2034 if(pos == std::string::npos) {
2041 || std::isdigit(dateTimeString[pos - 1]) == 0
2044 pos == dateTimeString.length() - 1
2045 || std::isdigit(dateTimeString[pos + 1]) == 0
2049 dateTimeString.insert(pos, 1,
'0');
2067 inline void fixYear(std::string& sqlTimeStamp, std::string_view format) {
2069 format.find(
"%y") != std::string_view::npos
2077 sqlTimeStamp[0] =
'2';
2078 sqlTimeStamp[1] =
'0';
2115 std::string& formatString,
2116 const std::string& dateTimeString,
2120 const auto formatPos{formatString.find(
"%p")};
2122 if(formatPos == std::string::npos) {
2128 while(pos < dateTimeString.length()) {
2130 auto amPos1{dateTimeString.find(
"am", pos)};
2131 auto amPos2{dateTimeString.find(
"AM", pos)};
2132 auto amPos{std::min(amPos1, amPos2)};
2134 if(amPos != std::string::npos) {
2140 || std::isspace(dateTimeString[amPos - 1]) != 0
2141 || std::ispunct(dateTimeString[amPos - 1]) != 0
2142 || std::isdigit(dateTimeString[amPos - 1]) != 0
2144 amPos == dateTimeString.length() -
amPmLength 2145 || std::isspace(dateTimeString[amPos +
amPmLength]) != 0
2146 || std::ispunct(dateTimeString[amPos +
amPmLength]) != 0
2147 || std::isdigit(dateTimeString[amPos +
amPmLength]) != 0
2163 auto pmPos1{dateTimeString.find(
"pm", pos)};
2164 auto pmPos2{dateTimeString.find(
"PM", pos)};
2165 auto pmPos{std::min(pmPos1, pmPos2)};
2167 if(pmPos != std::string::npos) {
2168 if(pmPos > newPos) {
2175 || std::isspace(dateTimeString[pmPos - 1]) != 0
2176 || std::ispunct(dateTimeString[pmPos - 1]) != 0
2177 || std::isdigit(dateTimeString[pmPos - 1]) != 0
2179 pmPos == dateTimeString.length() -
amPmLength 2180 || std::isspace(dateTimeString[pmPos +
amPmLength]) != 0
2181 || std::ispunct(dateTimeString[pmPos +
amPmLength]) != 0
2182 || std::isdigit(dateTimeString[pmPos +
amPmLength]) != 0
constexpr auto englishLocalePrefix
The prefix for English locales.
Definition: DateTime.hpp:116
std::vector< std::string > getDayGap(const std::string &first, const std::string &second)
Gets all days that lie inbetween two dates.
Definition: DateTime.hpp:1271
constexpr std::array russianOrdinalSuffixes
An array containing Russian ordinal suffixes to be stripped from numbers.
Definition: DateTime.hpp:100
constexpr auto year
The current year.
Definition: App.hpp:102
void convertTimeStampToSQLTimeStamp(std::string &timeStamp)
Converts a timestamp in the YYYYMMDDHHMMSS format to a MySQL timestamp in the YYYY-MM-DD HH:MM:SS for...
Definition: DateTime.hpp:693
constexpr auto base10
Base of decimal numbers.
Definition: DateTime.hpp:197
constexpr auto unixTimeFormatXOffset
The position of the beginning of a UNIX time format offset.
Definition: DateTime.hpp:87
std::vector< std::string > getMonthGap(const std::string &first, const std::string &second)
Gets all months that lie inbetween two months.
Definition: DateTime.hpp:1335
constexpr auto millisecondsPerHour
The number of milliseconds per hour used for date/time formatting.
Definition: DateTime.hpp:158
void removeOrdinals(const std::array< std::string_view, N > &suffixes, std::string &strInOut)
Removes all ordinal suffixes after numbers in the given string.
Definition: DateTime.hpp:1455
constexpr auto isoMonthPos
The position of the month in an ISO date (YYYY-MM-DD).
Definition: DateTime.hpp:188
std::string microsecondsToString(std::uint64_t microseconds)
Converts microseconds into a well-formatted string.
Definition: DateTime.hpp:859
void handle12hTime(std::string &formatString, const std::string &dateTimeString, bool &outIsAm, bool &outIsPm)
Handles 12h-time manually to avoid buggy standard library implementations.
Definition: DateTime.hpp:2114
void convertLongDateTimeToSQLTimeStamp(std::string &dateTime)
Converts a date/time formatted in a “long” format into the format YYYY-MM-DD HH:MM:SS.
Definition: DateTime.hpp:361
constexpr std::uint8_t dateWeeks
Group dates by weeks.
Definition: DateTime.hpp:209
constexpr auto minTwoDigitYear
Consider two-digit years before this year as being in the 2000s.
Definition: DateTime.hpp:194
constexpr auto ukrainianLocalePrefix
The prefix for Ukrainian locales.
Definition: DateTime.hpp:125
constexpr auto centuryFrom
The two digits from which two-digit years will be interpreted as years after 2000.
Definition: DateTime.hpp:140
constexpr auto isoMonthLength
The length of the month in an ISO date (YYYY-MM-DD).
Definition: DateTime.hpp:191
constexpr auto amPmLength
The length of the 12-h suffix (AM / PM).
Definition: DateTime.hpp:131
constexpr auto microsecondsPerHour
The number of microseconds per hour used for date/time formatting.
Definition: DateTime.hpp:155
constexpr auto longDateTime
The 'long' format for date/times.
Definition: DateTime.hpp:72
std::vector< std::string > getDateGap(const std::string &first, const std::string &second, std::uint8_t resolution)
Gets all dates that lies between two dates.
Definition: DateTime.hpp:1154
void fixFinnishMonths(std::string_view locale, std::string_view format, std::string &strInOut)
Fixes semi-abbreviated Finnish month names (huhtik, touko, etc.), if the locale is Finnish...
Definition: DateTime.hpp:1959
#define MAIN_EXCEPTION_CLASS()
Macro used to easily define classes for general exceptions.
Definition: Exception.hpp:50
constexpr auto reducedToMonthLength
Length of date, reduced to month (YYYY-MM)
Definition: DateTime.hpp:200
void extendSingleDigits(std::string &dateTimeString)
Extends single digits (1-9) by adding a leading zero to each of them.
Definition: DateTime.hpp:2028
constexpr auto millisecondsPerMinute
The number of milliseconds per minute used for date/time formatting.
Definition: DateTime.hpp:167
constexpr auto finnishLocalePrefix
The prefix for Finnish locales.
Definition: DateTime.hpp:128
constexpr std::uint8_t dateYears
Group dates by years.
Definition: DateTime.hpp:227
constexpr auto millisecondsPerDay
The number of milliseconds per day used for date/time formatting.
Definition: DateTime.hpp:149
void fixYear(std::string &sqlTimeStamp, std::string_view format)
Changes a year before 1969 into a year after 2000, if it has been parsed from two digits...
Definition: DateTime.hpp:2067
constexpr std::array englishOrdinalSuffixes
An array containing English ordinal suffixes to be stripped from numbers.
Definition: DateTime.hpp:90
constexpr std::uint8_t dateDays
Group dates by days.
Definition: DateTime.hpp:215
constexpr auto unixTimeFormat
The keyword to use a UNIX time format.
Definition: DateTime.hpp:75
void fixFrenchMonths(std::string_view locale, std::string &strInOut)
Replaces the abbreviation avr. for the month of april (avril) in the given string, if the locale is French.
Definition: DateTime.hpp:1563
std::string now()
Formats the current date/time as string in the format YYYY-MM-DD HH:MM:SS.
Definition: DateTime.hpp:1045
constexpr auto first
Index of the first byte.
Definition: Bytes.hpp:57
constexpr auto microsecondsPerMinute
The number of microseconds per minute used for date/time formatting.
Definition: DateTime.hpp:164
constexpr std::array frenchOrdinalSuffixes
An array containing French ordinal suffix to be stripped from numbers.
Definition: DateTime.hpp:95
constexpr auto unixTimeFormatPlus
The keyword to use a UNIX time format plus an offset.
Definition: DateTime.hpp:78
constexpr auto isoDateLength
The length of a date in valid ISO format (YYYY-MM-DD).
Definition: DateTime.hpp:182
constexpr auto yearLength
The length of a year.
Definition: DateTime.hpp:185
void fixUkrainianMonths(std::string_view locale, std::string &strInOut, std::string &formatInOut)
Shortens Ukrainian month names, if the locale is Ukrainian.
Definition: DateTime.hpp:1790
constexpr auto microsecondsPerSecond
The number of microseconds per second used for date/time formatting.
Definition: DateTime.hpp:173
constexpr auto sqlTimeStampLength
The length of a formatted time stamp in the MySQL database.
Definition: DateTime.hpp:113
void fixRussianMonths(std::string_view locale, std::string &strInOut, std::string &formatInOut)
Shortens Russian month names and replaces the abbreviations май and сент, if the locale is Russian...
Definition: DateTime.hpp:1602
constexpr auto secondsPerHour
The number of seconds per hour used for date/time formatting.
Definition: DateTime.hpp:161
constexpr auto second
Index of the second byte.
Definition: Bytes.hpp:60
constexpr auto sqlTimeStamp
The date/time format used by the MySQL database (as C string).
Definition: DateTime.hpp:110
void replaceAll(std::string &strInOut, std::string_view needle, std::string_view replacement)
Replaces all occurences within a string with another string.
Definition: Strings.hpp:246
constexpr auto daysPerWeek
Number of days in a week.
Definition: DateTime.hpp:203
void convert12hTo24h(int &hour, bool isPm)
Converts an hour from the 12h to the 24h system.
Definition: DateTime.hpp:742
Class for date/time locale exception.
Definition: DateTime.hpp:337
constexpr auto secondsPerMinute
The number of seconds per minute used for date/time formatting.
Definition: DateTime.hpp:170
constexpr auto secondsPerDay
The number of seconds per day used for date/time formatting.
Definition: DateTime.hpp:152
constexpr auto microsecondsPerMillisecond
The number of microseconds per millisecond used for date/time formatting.
Definition: DateTime.hpp:179
bool isISODateInRange(std::string_view isoDate, std::string_view rangeFrom, std::string_view rangeTo)
Checks whether the given ISO date is in the given range of dates.
Definition: DateTime.hpp:1105
constexpr std::uint8_t dateMonths
Group dates by months.
Definition: DateTime.hpp:221
void convertSQLTimeStampToTimeStamp(std::string &timeStamp)
Converts a MySQL timestamp in the YYYY-MM-DD HH:MM:SS format to a timestamp in the YYYYMMDDHHMMSS for...
Definition: DateTime.hpp:712
std::string getYearAndWeek(const std::string &date)
Get the year and the ISO week number for a specific date.
Definition: DateTime.hpp:775
constexpr auto millisecondsPerSecond
The number of milliseconds per second used for date/time formatting.
Definition: DateTime.hpp:176
std::string secondsToString(std::uint64_t seconds)
Converts seconds into a well-formatted string.
Definition: DateTime.hpp:995
constexpr auto hourNoonMidnight
The hour of noon and midnight.
Definition: DateTime.hpp:137
constexpr auto microsecondsPerDay
The number of microseconds per day used for date/time formatting.
Definition: DateTime.hpp:146
void convertCustomDateTimeToSQLTimeStamp(std::string &dateTime, const std::string &customFormat)
Converts date/time with a custom format into the format YYYY-MM-DD HH:MM:SS.
Definition: DateTime.hpp:398
void reduceDate(std::string &date, std::uint8_t resolution)
Reduce a date to the specified resolution.
Definition: DateTime.hpp:807
std::string millisecondsToString(std::uint64_t milliseconds)
Converts milliseconds into a well-formatted string.
Definition: DateTime.hpp:933
constexpr auto unixTimeFormatXLength
The length of the keyword to use a UNIX time format with offset.
Definition: DateTime.hpp:84
bool isValidISODate(const std::string &isoDate)
Checks whether a string contains a valid date in the ISO format.
Definition: DateTime.hpp:1071
std::vector< std::string > getWeekGap(const std::string &first, const std::string &second)
Gets all ISO week numbers that lie inbetween two week numbers.
Definition: DateTime.hpp:1207
#define MAIN_EXCEPTION_SUBCLASS(NAME)
Macro used to easily define classes for specific exceptions.
Definition: Exception.hpp:65
Namespace for global date/time helper functions.
Definition: DateTime.hpp:60
constexpr auto yearsPerCentury
The number of years in a century.
Definition: DateTime.hpp:143
constexpr std::array ukrainianOrdinalSuffixes
An array containing Ukrainian ordinal suffixes to be stripped from numbers.
Definition: DateTime.hpp:105
constexpr auto unixTimeFormatMinus
The keyword to use a UNIX time format minus an offset.
Definition: DateTime.hpp:81
Class for date/time exceptions.
Definition: DateTime.hpp:330
std::vector< std::string > getYearGap(const std::string &first, const std::string &second)
Gets all years that lies inbetween two years.
Definition: DateTime.hpp:1399
constexpr auto frenchLocalePrefix
The prefix for French locales.
Definition: DateTime.hpp:119
constexpr auto hourChange
The number of hours to be added to a PM time, or to be subtracted from a 12th hour AM time...
Definition: DateTime.hpp:134
constexpr auto russianLocalePrefix
The prefix for Russian locales.
Definition: DateTime.hpp:122