KiCad PCB EDA Suite
Loading...
Searching...
No Matches
calc_parser::DATE_UTILS Class Reference

Static Public Member Functions

static auto DaysToYmd (int aDaysSinceEpoch) -> std::tuple< int, int, int >
 
static auto YmdToDays (int aYear, int aMonth, int aDay) -> int
 
static auto ParseDate (const std::string &aDateStr) -> std::optional< int >
 
static auto FormatDate (int aDaysSinceEpoch, const std::string &aFormat) -> std::string
 
static auto GetWeekdayName (int aDaysSinceEpoch) -> std::string
 
static auto GetCurrentDays () -> int
 
static auto GetCurrentTimestamp () -> double
 

Static Private Member Functions

static auto isLeapYear (int aYear) -> bool
 
static auto daysInYear (int aYear) -> int
 
static auto daysInMonthForYear (int aMonth, int aYear) -> int
 

Static Private Attributes

static constexpr int epochYear = 1970
 
static constexpr std::array< int, 12 > daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
 
static constexpr std::array< const char *, 12 > monthNames
 
static constexpr std::array< const char *, 12 > monthAbbrev
 
static constexpr std::array< const char *, 7 > weekdayNames
 

Detailed Description

Definition at line 29 of file text_eval_parser.cpp.

Member Function Documentation

◆ daysInMonthForYear()

static auto calc_parser::DATE_UTILS::daysInMonthForYear ( int aMonth,
int aYear ) -> int
inlinestaticprivate

Definition at line 56 of file text_eval_parser.cpp.

References daysInMonth, and isLeapYear().

Referenced by DaysToYmd(), ParseDate(), and YmdToDays().

◆ daysInYear()

static auto calc_parser::DATE_UTILS::daysInYear ( int aYear) -> int
inlinestaticprivate

Definition at line 51 of file text_eval_parser.cpp.

References isLeapYear().

Referenced by DaysToYmd(), and YmdToDays().

◆ DaysToYmd()

static auto calc_parser::DATE_UTILS::DaysToYmd ( int aDaysSinceEpoch) -> std::tuple<int, int, int>
inlinestatic

Definition at line 65 of file text_eval_parser.cpp.

References daysInMonthForYear(), daysInYear(), and epochYear.

Referenced by FormatDate().

◆ FormatDate()

static auto calc_parser::DATE_UTILS::FormatDate ( int aDaysSinceEpoch,
const std::string & aFormat ) -> std::string
inlinestatic

Definition at line 273 of file text_eval_parser.cpp.

References DaysToYmd(), monthAbbrev, and monthNames.

Referenced by calc_parser::EVAL_VISITOR::evaluateFunction().

◆ GetCurrentDays()

static auto calc_parser::DATE_UTILS::GetCurrentDays ( ) -> int
inlinestatic

Definition at line 307 of file text_eval_parser.cpp.

Referenced by calc_parser::EVAL_VISITOR::evaluateFunction().

◆ GetCurrentTimestamp()

static auto calc_parser::DATE_UTILS::GetCurrentTimestamp ( ) -> double
inlinestatic

Definition at line 314 of file text_eval_parser.cpp.

Referenced by calc_parser::EVAL_VISITOR::evaluateFunction().

◆ GetWeekdayName()

static auto calc_parser::DATE_UTILS::GetWeekdayName ( int aDaysSinceEpoch) -> std::string
inlinestatic

Definition at line 297 of file text_eval_parser.cpp.

References weekdayNames.

Referenced by calc_parser::EVAL_VISITOR::evaluateFunction().

◆ isLeapYear()

static auto calc_parser::DATE_UTILS::isLeapYear ( int aYear) -> bool
inlinestaticprivate

Definition at line 46 of file text_eval_parser.cpp.

Referenced by daysInMonthForYear(), and daysInYear().

◆ ParseDate()

static auto calc_parser::DATE_UTILS::ParseDate ( const std::string & aDateStr) -> std::optional<int>
inlinestatic

Definition at line 120 of file text_eval_parser.cpp.

References daysInMonthForYear(), and YmdToDays().

Referenced by calc_parser::EVAL_VISITOR::evaluateFunction().

◆ YmdToDays()

static auto calc_parser::DATE_UTILS::YmdToDays ( int aYear,
int aMonth,
int aDay ) -> int
inlinestatic

Definition at line 98 of file text_eval_parser.cpp.

References daysInMonthForYear(), daysInYear(), and epochYear.

Referenced by ParseDate().

Member Data Documentation

◆ daysInMonth

std::array<int, 12> calc_parser::DATE_UTILS::daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
staticconstexprprivate

Definition at line 33 of file text_eval_parser.cpp.

Referenced by daysInMonthForYear().

◆ epochYear

int calc_parser::DATE_UTILS::epochYear = 1970
staticconstexprprivate

Definition at line 32 of file text_eval_parser.cpp.

Referenced by DaysToYmd(), and YmdToDays().

◆ monthAbbrev

std::array<const char*, 12> calc_parser::DATE_UTILS::monthAbbrev
staticconstexprprivate
Initial value:
= {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}

Definition at line 38 of file text_eval_parser.cpp.

Referenced by FormatDate().

◆ monthNames

std::array<const char*, 12> calc_parser::DATE_UTILS::monthNames
staticconstexprprivate
Initial value:
= {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
}

Definition at line 34 of file text_eval_parser.cpp.

Referenced by FormatDate().

◆ weekdayNames

std::array<const char*, 7> calc_parser::DATE_UTILS::weekdayNames
staticconstexprprivate
Initial value:
= {
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
}

Definition at line 42 of file text_eval_parser.cpp.

Referenced by GetWeekdayName().


The documentation for this class was generated from the following file: