changeset 281:3ede7be4f449

anime_season: forgot these
author Paper <paper@paper.us.eu.org>
date Mon, 06 May 2024 17:44:16 -0400
parents 9b6e12c14a1e
children 19eb6c4dca78
files include/core/anime_season.h src/core/anime_season.cc
diffstat 2 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/core/anime_season.h	Mon May 06 17:44:16 2024 -0400
@@ -0,0 +1,13 @@
+#ifndef MINORI_CORE_ANIME_SEASON_H_
+#define MINORI_CORE_ANIME_SEASON_H_
+
+#include "core/anime.h" /* SeriesSeason */
+#include "core/date.h" /* Date::Month */
+
+namespace Anime {
+
+SeriesSeason GetSeasonForMonth(Date::Month month);
+
+}
+
+#endif // MINORI_CORE_ANIME_SEASON_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/anime_season.cc	Mon May 06 17:44:16 2024 -0400
@@ -0,0 +1,20 @@
+#include "core/anime_season.h"
+
+namespace Anime {
+
+/* MAL has a different idea of seasons than Kitsu/AniList
+ * prepare ahead of time for this discrepancy. */
+SeriesSeason GetSeasonForMonth(Date::Month month) {
+	switch (month) {
+		case Date::Month::Jan: case Date::Month::Feb: case Date::Month::Mar:
+			return SeriesSeason::Winter;
+		case Date::Month::Apr: case Date::Month::May: case Date::Month::Jun:
+			return SeriesSeason::Spring;
+		case Date::Month::Jul: case Date::Month::Aug: case Date::Month::Sep:
+			return SeriesSeason::Summer;
+		case Date::Month::Oct: case Date::Month::Nov: case Date::Month::Dec:
+			return SeriesSeason::Fall;
+	}
+}
+
+}