ISO8601d: Added ::daysInMonth and tests
This commit is contained in:
@@ -806,6 +806,18 @@ bool ISO8601d::leapYear (int year)
|
||||
! (year % 400);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Static
|
||||
int ISO8601d::daysInMonth (int month, int year)
|
||||
{
|
||||
static int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
if (month == 2 && ISO8601d::leapYear (year))
|
||||
return 29;
|
||||
|
||||
return days[month - 1];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Static
|
||||
int ISO8601d::dayOfWeek (const std::string& input)
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
bool parse (const std::string&, std::string::size_type&, const std::string& format = "");
|
||||
|
||||
static bool leapYear (int);
|
||||
static int daysInMonth (int, int);
|
||||
|
||||
static int dayOfWeek (const std::string&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user