mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Date
- Simplified ::daysInMonth.
This commit is contained in:
parent
4a931868c1
commit
8861193999
1 changed files with 5 additions and 6 deletions
11
src/Date.cpp
11
src/Date.cpp
|
@ -387,13 +387,12 @@ bool Date::leapYear (int year)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::daysInMonth (int month, int year)
|
||||
{
|
||||
static int days[2][12] =
|
||||
{
|
||||
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
|
||||
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
|
||||
};
|
||||
static int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
return days[Date::leapYear (year) ? 1 : 0][month - 1];
|
||||
if (month == 2 && Date::leapYear (year))
|
||||
return 29;
|
||||
|
||||
return days[month - 1];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue