The datetime.cpp
File Reference
Included Headers
Classes Index
struct | SpecFormat |
struct | DateTimeField |
Typedefs Index
using | TMFieldAssigner = std::function< void(std::tm &, int value) > |
Functions Index
std::tm | getCurrentDateTime () |
Returns the filled in std::tm for the current date and time. More... | |
QCString | dateToString (DateTimeType includeTime) |
Returns the current date, when includeTime is set also the time is provided. More... | |
QCString | yearToString () |
Returns the current year as a string. More... | |
static void | determine_weekday (std::tm &tm) |
QCString | dateTimeFromString (const QCString &spec, std::tm &dt, int &format) |
Returns the filled in std::tm for a given string representing a date and/or time. More... | |
QCString | formatDateTime (const QCString &format, const std::tm &dt, int &formatUsed) |
Return a string representation for a given std::tm value that is formatted according to the pattern given by a format. More... | |
Variables Index
static std::array | g_specFormats = ... |
static std::array | g_assignValues = ... |
Typedefs
TMFieldAssigner
|
Definition at line 90 of file datetime.cpp.
Functions
dateTimeFromString()
|
Returns the filled in std::tm for a given string representing a date and/or time.
- Parameters
-
[in] spec The string representation of the date and/or time Possible formats:
- the empty string: the current date and time is returned
- YYYY-MM-DD HH:MM:SS: the date and time are fully specified
- YYYY-MM-DD HH:MM: the date and time without seconds
- YYYY-MM-DD: the date without time
- HH:MM:SS: the time with seconds but without date
- HH:MM: the time without seconds and without date
[out] dt The corresponding datetime value.
[out] format The parts that have been found in spec; a bitwise or of SF_Date, SF_Time and SF_Seconds.
- Returns
An empty string if the spec has a supported format, or an error message if the format is invalid.
Definition at line 134 of file datetime.cpp.
References DateTimeField::assigner, determine_weekday, g_assignValues, g_specFormats, getCurrentDateTime, QCString::isEmpty, reg::match, DateTimeField::maxVal, DateTimeField::minVal, DateTimeField::name, SF_Date, SF_Seconds, SF_Time, QCString::sprintf and QCString::str.
Referenced by DocPara::handleShowDate and showDate.
dateToString()
|
Returns the current date, when includeTime is set also the time is provided.
- Parameters
-
[in] includeTime include the time in the output
Definition at line 63 of file datetime.cpp.
References getCurrentDateTime and theTranslator.
Referenced by RTFGenerator::endIndexSection, ManGenerator::endTitleHead, recordMetadata, substituteKeywords, substituteLatexKeywords and writeDefaultStyleSheet.
determine_weekday()
| static |
Definition at line 121 of file datetime.cpp.
Referenced by dateTimeFromString.
formatDateTime()
|
Return a string representation for a given std::tm value that is formatted according to the pattern given by a format.
- Parameters
-
[in] format the string used for format the date and time, e.g. Y-m-d
[in] dt the date and time value to fill in
[out] formatUsed A bitwise OR of SF_Date, SF_Time and SF_Seconds representing the the types of markers found in the format string.
Definition at line 175 of file datetime.cpp.
References GrowBuf::addChar, GrowBuf::addInt, GrowBuf::addStr, QCString::data, GrowBuf::get, SF_Date, SF_Seconds, SF_Time and theTranslator.
Referenced by DocPara::handleShowDate and showDate.
getCurrentDateTime()
|
Returns the filled in std::tm for the current date and time.
Definition at line 30 of file datetime.cpp.
References FALSE, Portable::getenv, QCString::isEmpty, QCString::toUInt64, TRUE and warn_uncond.
Referenced by dateTimeFromString, dateToRTFDateString, dateToString and yearToString.
yearToString()
|
Returns the current year as a string.
Definition at line 76 of file datetime.cpp.
References getCurrentDateTime and QCString::setNum.
Referenced by substituteKeywords.
Variables
g_assignValues
| static |
- Initialiser
-
{ DateTimeField{ [](std::tm &tm,int value) { tm.tm_year = value-1900; }, 1900, 9999, "year" }, DateTimeField{ [](std::tm &tm,int value) { tm.tm_mon = value-1; }, 1, 12, "month" }, DateTimeField{ [](std::tm &tm,int value) { tm.tm_mday = value; }, 1, 31, "day" }, DateTimeField{ [](std::tm &tm,int value) { tm.tm_hour = value; }, 0, 23, "hour" }, DateTimeField{ [](std::tm &tm,int value) { tm.tm_min = value; }, 0, 59, "minute" }, DateTimeField{ [](std::tm &tm,int value) { tm.tm_sec = value; }, 0, 59, "second" } }
Definition at line 110 of file datetime.cpp.
Referenced by dateTimeFromString.
g_specFormats
| static |
- Initialiser
-
{ SpecFormat{ std::string_view(R"((\d+)-(\d+)-(\d+)\s*(\d+):(\d+):(\d+))"), 6, 0, SF_Date|SF_Time|SF_Seconds }, SpecFormat{ std::string_view(R"((\d+)-(\d+)-(\d+)\s*(\d+):(\d+))"), 5, 0, SF_Date|SF_Time }, SpecFormat{ std::string_view(R"((\d+)-(\d+)-(\d+))"), 3, 0, SF_Date }, SpecFormat{ std::string_view(R"((\d+):(\d+):(\d+))"), 3, 3, SF_Time|SF_Seconds }, SpecFormat{ std::string_view(R"((\d+):(\d+))"), 2, 3, SF_Time } }
Definition at line 100 of file datetime.cpp.
Referenced by dateTimeFromString.
Generated via doxygen2docusaurus by Doxygen 1.14.0.