Mercurial > minori
diff src/core/anime_season.cc @ 369:47c9f8502269
*: clang-format all the things
I've edited the formatting a bit. Now pointer asterisks (and reference
ampersands) are on the variable instead of the type, as well as having
newlines for function braces (but nothing else)
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 10:16:02 -0400 |
parents | 6b0768158dcd |
children |
line wrap: on
line diff
--- a/src/core/anime_season.cc Fri Jul 25 10:05:23 2025 -0400 +++ b/src/core/anime_season.cc Fri Jul 25 10:16:02 2025 -0400 @@ -3,49 +3,59 @@ namespace Anime { -static bool WinterStartsInDecember() { +static bool WinterStartsInDecember() +{ switch (session.config.service) { - case Service::MyAnimeList: - return false; - default: - return true; + case Service::MyAnimeList: return false; + default: return true; } } -static Season::Name GetSeasonForMonth(Date::Month month) { +static Season::Name GetSeasonForMonth(Date::Month month) +{ if (WinterStartsInDecember()) { switch (month) { - case Date::Month::Dec: case Date::Month::Jan: case Date::Month::Feb: - return Season::Name::Winter; - case Date::Month::Mar: case Date::Month::Apr: case Date::Month::May: - return Season::Name::Spring; - case Date::Month::Jun: case Date::Month::Jul: case Date::Month::Aug: - return Season::Name::Summer; - case Date::Month::Sep: case Date::Month::Oct: case Date::Month::Nov: - return Season::Name::Autumn; + case Date::Month::Dec: + case Date::Month::Jan: + case Date::Month::Feb: return Season::Name::Winter; + case Date::Month::Mar: + case Date::Month::Apr: + case Date::Month::May: return Season::Name::Spring; + case Date::Month::Jun: + case Date::Month::Jul: + case Date::Month::Aug: return Season::Name::Summer; + case Date::Month::Sep: + case Date::Month::Oct: + case Date::Month::Nov: return Season::Name::Autumn; default: return Season::Name::Unknown; } } else { switch (month) { - case Date::Month::Jan: case Date::Month::Feb: case Date::Month::Mar: - return Season::Name::Winter; - case Date::Month::Apr: case Date::Month::May: case Date::Month::Jun: - return Season::Name::Spring; - case Date::Month::Jul: case Date::Month::Aug: case Date::Month::Sep: - return Season::Name::Summer; - case Date::Month::Oct: case Date::Month::Nov: case Date::Month::Dec: - return Season::Name::Autumn; + case Date::Month::Jan: + case Date::Month::Feb: + case Date::Month::Mar: return Season::Name::Winter; + case Date::Month::Apr: + case Date::Month::May: + case Date::Month::Jun: return Season::Name::Spring; + case Date::Month::Jul: + case Date::Month::Aug: + case Date::Month::Sep: return Season::Name::Summer; + case Date::Month::Oct: + case Date::Month::Nov: + case Date::Month::Dec: return Season::Name::Autumn; default: return Season::Name::Unknown; } } } -Season::Season(Season::Name s, Date::Year y) { +Season::Season(Season::Name s, Date::Year y) +{ season = s; year = y; } -Season::Season(const Date& date) { +Season::Season(const Date &date) +{ std::optional<Date::Month> month = date.GetMonth(); if (month) season = GetSeasonForMonth(month.value()); @@ -55,45 +65,59 @@ year = y.value(); } -bool Season::operator==(const Season& o) const { +bool Season::operator==(const Season &o) const +{ return (season == o.season && year == o.year); } -bool Season::operator!=(const Season& o) const { +bool Season::operator!=(const Season &o) const +{ return !(*this == o); } -bool Season::operator<(const Season& o) const { +bool Season::operator<(const Season &o) const +{ return std::tie(season, year) < std::tie(o.season, o.year); } -bool Season::operator>(const Season& o) const { +bool Season::operator>(const Season &o) const +{ return (o < *this); } -bool Season::operator<=(const Season& o) const { +bool Season::operator<=(const Season &o) const +{ return !(o > *this); } -bool Season::operator>=(const Season& o) const { +bool Season::operator>=(const Season &o) const +{ return !(*this < o); } -Season& Season::operator++() { +Season &Season::operator++() +{ switch (season) { case Season::Name::Winter: season = Season::Name::Spring; break; case Season::Name::Spring: season = Season::Name::Summer; break; case Season::Name::Summer: season = Season::Name::Autumn; break; - case Season::Name::Autumn: season = Season::Name::Winter; year++; break; + case Season::Name::Autumn: + season = Season::Name::Winter; + year++; + break; default: season = Season::Name::Unknown; break; } return *this; } -Season& Season::operator--() { +Season &Season::operator--() +{ switch (season) { - case Season::Name::Winter: season = Season::Name::Autumn; year--; break; + case Season::Name::Winter: + season = Season::Name::Autumn; + year--; + break; case Season::Name::Spring: season = Season::Name::Winter; break; case Season::Name::Summer: season = Season::Name::Spring; break; case Season::Name::Autumn: season = Season::Name::Summer; break; @@ -103,4 +127,4 @@ return *this; } -} +} // namespace Anime