Skip to content

Commit

Permalink
Simplify calcDayOfYear()
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Apr 15, 2024
1 parent 71edc37 commit ef90cd5
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions Sming/Core/DateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,23 +531,11 @@ String DateTime::format(const char* sFormat) const

void DateTime::calcDayOfYear()
{
DayofYear = 0;
uint16_t prevMonthDays{0};
for(unsigned m = dtJanuary; m < Month; ++m) {
switch(m) {
case dtSeptember:
case dtApril:
case dtJune:
case dtNovember:
DayofYear += 30;
break;
case dtFebruary:
DayofYear += isLeapYear(Year) ? 29 : 28;
break;
default:
DayofYear += 31;
}
prevMonthDays += getMonthDays(m, Year);
}
DayofYear += Day;
DayofYear = prevMonthDays + Day;
}

uint8_t DateTime::calcWeek(uint8_t firstDay) const
Expand Down

0 comments on commit ef90cd5

Please sign in to comment.