Code Cleanup

- Remove the code related to the format "day of year" (number of day starting
  from the January 1) as mktime does not allow to specify it with the field
  tm_yday.
- Cleaner check of the date (everything is done by Date::valid).
- Correct hour, minute and second is also checked.
This commit is contained in:
Louis-Claude Canon
2012-07-30 16:31:21 +02:00
committed by Paul Beckingham
parent b5cd5ea188
commit 384be4b249
4 changed files with 20 additions and 22 deletions

View File

@@ -339,7 +339,7 @@ bool Date::valid (const int d, const int y)
if (y < 0)
return false;
if (d < 0 || d > 365)
if (d < 1 || d > Date::daysInYear (y))
return false;
return true;
@@ -371,6 +371,12 @@ int Date::daysInMonth (int month, int year)
return days[Date::leapYear (year) ? 1 : 0][month - 1];
}
////////////////////////////////////////////////////////////////////////////////
int Date::daysInYear (int year)
{
return Date::leapYear (year) ? 366 : 365;
}
////////////////////////////////////////////////////////////////////////////////
std::string Date::monthName (int month)
{