Reworked to better match other languages

This commit is contained in:
2020-08-28 14:28:20 -04:00
parent 3757e2169c
commit 03882a9366

View File

@@ -36,7 +36,6 @@ A leap year occurs on any year evenly divisible by 4, but not on a century unles
#include <cinttypes>
#include <string>
#include <sstream>
#include "Stopwatch.hpp"
#include "Problems/Problem19.hpp"
@@ -68,20 +67,26 @@ Problem19::DAYS Problem19::getDay(unsigned int month, unsigned int day, unsigned
}
//Add the correct number of days for every month
while(currentMonth < month){
//31 day months
if(currentMonth == 2){
if(isLeapYear(currentYear)){
numDays += 29;
}
else{
numDays += 28;
}
}
else if((currentMonth == 1) || (currentMonth == 3) || (currentMonth == 5) || (currentMonth == 7) || (currentMonth == 8) || (currentMonth == 10) || (currentMonth == 12)){
numDays += 31;
}
else{
numDays += 30;
switch(currentMonth){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: numDays += 31; break;
case 4:
case 6:
case 9:
case 11: numDays += 30; break;
case 2:
if(isLeapYear(currentYear)){
numDays += 29;
}
else{
numDays += 28;
}
break;
}
++currentMonth;
}