|
crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
|
#include "Strings.hpp"#include "../Main/Exception.hpp"#include "../_extern/date/include/date/date.h"#include <algorithm>#include <array>#include <cctype>#include <chrono>#include <clocale>#include <cmath>#include <cstddef>#include <cstdint>#include <cstdlib>#include <ctime>#include <exception>#include <iomanip>#include <locale>#include <sstream>#include <stdexcept>#include <string>#include <string_view>#include <vector>

Go to the source code of this file.
Classes | |
| class | crawlservpp::Helper::DateTime::Exception |
| Class for date/time exceptions. More... | |
| class | crawlservpp::Helper::DateTime::LocaleException |
| Class for date/time locale exception. More... | |
Namespaces | |
| crawlservpp::Helper::DateTime | |
| Namespace for global date/time helper functions. | |
Constants | |
| constexpr auto | crawlservpp::Helper::DateTime::longDateTime {"%a, %d %b %Y %T %Z"} |
| The 'long' format for date/times. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::unixTimeFormat {"UNIX"sv} |
| The keyword to use a UNIX time format. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::unixTimeFormatPlus {"UNIX+"sv} |
| The keyword to use a UNIX time format plus an offset. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::unixTimeFormatMinus {"UNIX-"sv} |
| The keyword to use a UNIX time format minus an offset. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::unixTimeFormatXLength {5} |
| The length of the keyword to use a UNIX time format with offset. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::unixTimeFormatXOffset {4} |
| The position of the beginning of a UNIX time format offset. More... | |
| constexpr std::array | crawlservpp::Helper::DateTime::englishOrdinalSuffixes |
| An array containing English ordinal suffixes to be stripped from numbers. More... | |
| constexpr std::array | crawlservpp::Helper::DateTime::frenchOrdinalSuffixes |
| An array containing French ordinal suffix to be stripped from numbers. More... | |
| constexpr std::array | crawlservpp::Helper::DateTime::russianOrdinalSuffixes |
| An array containing Russian ordinal suffixes to be stripped from numbers. More... | |
| constexpr std::array | crawlservpp::Helper::DateTime::ukrainianOrdinalSuffixes |
| An array containing Ukrainian ordinal suffixes to be stripped from numbers. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::sqlTimeStamp {"%F %T"} |
The date/time format used by the MySQL database (as C string). More... | |
| constexpr auto | crawlservpp::Helper::DateTime::sqlTimeStampLength {19} |
| The length of a formatted time stamp in the MySQL database. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::englishLocalePrefix {"en"sv} |
| The prefix for English locales. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::frenchLocalePrefix {"fr"sv} |
| The prefix for French locales. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::russianLocalePrefix {"ru"sv} |
| The prefix for Russian locales. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::ukrainianLocalePrefix {"uk"sv} |
| The prefix for Ukrainian locales. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::finnishLocalePrefix {"fi"sv} |
| The prefix for Finnish locales. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::amPmLength {2} |
The length of the 12-h suffix (AM / PM). More... | |
| constexpr auto | crawlservpp::Helper::DateTime::hourChange {12} |
The number of hours to be added to a PM time, or to be subtracted from a 12th hour AM time. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::hourNoonMidnight {12} |
| The hour of noon and midnight. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::centuryFrom {69} |
| The two digits from which two-digit years will be interpreted as years after 2000. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::yearsPerCentury {100} |
| The number of years in a century. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::microsecondsPerDay {86400000000} |
| The number of microseconds per day used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::millisecondsPerDay {86400000} |
| The number of milliseconds per day used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::secondsPerDay {86400} |
| The number of seconds per day used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::microsecondsPerHour {3600000000} |
| The number of microseconds per hour used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::millisecondsPerHour {3600000} |
| The number of milliseconds per hour used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::secondsPerHour {3600} |
| The number of seconds per hour used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::microsecondsPerMinute {60000000} |
| The number of microseconds per minute used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::millisecondsPerMinute {60000} |
| The number of milliseconds per minute used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::secondsPerMinute {60} |
| The number of seconds per minute used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::microsecondsPerSecond {1000000} |
| The number of microseconds per second used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::millisecondsPerSecond {1000} |
| The number of milliseconds per second used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::microsecondsPerMillisecond {1000} |
| The number of microseconds per millisecond used for date/time formatting. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::isoDateLength {10} |
The length of a date in valid ISO format (YYYY-MM-DD). More... | |
| constexpr auto | crawlservpp::Helper::DateTime::yearLength {4} |
| The length of a year. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::isoMonthPos {5} |
The position of the month in an ISO date (YYYY-MM-DD). More... | |
| constexpr auto | crawlservpp::Helper::DateTime::isoMonthLength {2} |
The length of the month in an ISO date (YYYY-MM-DD). More... | |
| constexpr auto | crawlservpp::Helper::DateTime::minTwoDigitYear {1969} |
| Consider two-digit years before this year as being in the 2000s. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::base10 {10} |
| Base of decimal numbers. More... | |
| constexpr auto | crawlservpp::Helper::DateTime::reducedToMonthLength {7} |
Length of date, reduced to month (YYYY-MM) More... | |
| constexpr auto | crawlservpp::Helper::DateTime::daysPerWeek {7} |
| Number of days in a week. More... | |
| constexpr std::uint8_t | crawlservpp::Helper::DateTime::dateWeeks {0} |
| Group dates by weeks. More... | |
| constexpr std::uint8_t | crawlservpp::Helper::DateTime::dateDays {1} |
| Group dates by days. More... | |
| constexpr std::uint8_t | crawlservpp::Helper::DateTime::dateMonths {2} |
| Group dates by months. More... | |
| constexpr std::uint8_t | crawlservpp::Helper::DateTime::dateYears {3} |
| Group dates by years. More... | |
Conversion | |
| void | crawlservpp::Helper::DateTime::convertLongDateTimeToSQLTimeStamp (std::string &dateTime) |
Converts a date/time formatted in a “long” format into the format YYYY-MM-DD HH:MM:SS. More... | |
| void | crawlservpp::Helper::DateTime::convertCustomDateTimeToSQLTimeStamp (std::string &dateTime, const std::string &customFormat) |
Converts date/time with a custom format into the format YYYY-MM-DD HH:MM:SS. More... | |
| void | crawlservpp::Helper::DateTime::convertCustomDateTimeToSQLTimeStamp (std::string &dateTime, const std::string &customFormat, const std::string &locale) |
Converts date/time with a custom format into the format YYYY-MM-DD HH:MM:SS. More... | |
| void | crawlservpp::Helper::DateTime::convertTimeStampToSQLTimeStamp (std::string &timeStamp) |
Converts a timestamp in the YYYYMMDDHHMMSS format to a MySQL timestamp in the YYYY-MM-DD HH:MM:SS format. More... | |
| void | crawlservpp::Helper::DateTime::convertSQLTimeStampToTimeStamp (std::string &timeStamp) |
Converts a MySQL timestamp in the YYYY-MM-DD HH:MM:SS format to a timestamp in the YYYYMMDDHHMMSS format. More... | |
| void | crawlservpp::Helper::DateTime::convert12hTo24h (int &hour, bool isPm) |
| Converts an hour from the 12h to the 24h system. More... | |
| std::string | crawlservpp::Helper::DateTime::getYearAndWeek (const std::string &date) |
| Get the year and the ISO week number for a specific date. More... | |
| void | crawlservpp::Helper::DateTime::reduceDate (std::string &date, std::uint8_t resolution) |
| Reduce a date to the specified resolution. More... | |
Formatting | |
| std::string | crawlservpp::Helper::DateTime::microsecondsToString (std::uint64_t microseconds) |
| Converts microseconds into a well-formatted string. More... | |
| std::string | crawlservpp::Helper::DateTime::millisecondsToString (std::uint64_t milliseconds) |
| Converts milliseconds into a well-formatted string. More... | |
| std::string | crawlservpp::Helper::DateTime::secondsToString (std::uint64_t seconds) |
| Converts seconds into a well-formatted string. More... | |
| std::string | crawlservpp::Helper::DateTime::now () |
Formats the current date/time as string in the format YYYY-MM-DD HH:MM:SS. More... | |
Verification | |
| bool | crawlservpp::Helper::DateTime::isValidISODate (const std::string &isoDate) |
| Checks whether a string contains a valid date in the ISO format. More... | |
Comparison | |
| bool | crawlservpp::Helper::DateTime::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. More... | |
Gaps inbetween Dates | |
| std::vector< std::string > | crawlservpp::Helper::DateTime::getDateGap (const std::string &first, const std::string &second, std::uint8_t resolution) |
| Gets all dates that lies between two dates. More... | |
| std::vector< std::string > | crawlservpp::Helper::DateTime::getWeekGap (const std::string &first, const std::string &second) |
| Gets all ISO week numbers that lie inbetween two week numbers. More... | |
| std::vector< std::string > | crawlservpp::Helper::DateTime::getDayGap (const std::string &first, const std::string &second) |
| Gets all days that lie inbetween two dates. More... | |
| std::vector< std::string > | crawlservpp::Helper::DateTime::getMonthGap (const std::string &first, const std::string &second) |
| Gets all months that lie inbetween two months. More... | |
| std::vector< std::string > | crawlservpp::Helper::DateTime::getYearGap (const std::string &first, const std::string &second) |
| Gets all years that lies inbetween two years. More... | |
Helpers | |
| template<std::size_t N> | |
| void | crawlservpp::Helper::DateTime::removeOrdinals (const std::array< std::string_view, N > &suffixes, std::string &strInOut) |
| Removes all ordinal suffixes after numbers in the given string. More... | |
| template<std::size_t N> | |
| void | crawlservpp::Helper::DateTime::removeOrdinals (std::string_view currentLocale, std::string_view localePrefix, const std::array< std::string_view, N > &suffixes, std::string &strInOut) |
| Removes all ordinal suffixes after numbers in the given string, if the current locale matches the given locale. More... | |
| void | crawlservpp::Helper::DateTime::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. More... | |
| void | crawlservpp::Helper::DateTime::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. More... | |
| void | crawlservpp::Helper::DateTime::fixUkrainianMonths (std::string_view locale, std::string &strInOut, std::string &formatInOut) |
| Shortens Ukrainian month names, if the locale is Ukrainian. More... | |
| void | crawlservpp::Helper::DateTime::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. More... | |
| void | crawlservpp::Helper::DateTime::extendSingleDigits (std::string &dateTimeString) |
Extends single digits (1-9) by adding a leading zero to each of them. More... | |
| void | crawlservpp::Helper::DateTime::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. More... | |
| void | crawlservpp::Helper::DateTime::handle12hTime (std::string &formatString, const std::string &dateTimeString, bool &outIsAm, bool &outIsPm) |
| Handles 12h-time manually to avoid buggy standard library implementations. More... | |