Mercurial > minori
diff src/core/date.cc @ 317:b1f4d1867ab1
services: VERY initial Kitsu support
it only supports user authentication for now, but it's definitely
a start.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 04:07:10 -0400 |
parents | 862d0d8619f6 |
children | d928ec7b6a0d |
line wrap: on
line diff
--- a/src/core/date.cc Tue Jun 11 15:11:09 2024 -0400 +++ b/src/core/date.cc Wed Jun 12 04:07:10 2024 -0400 @@ -5,6 +5,7 @@ #include <QDebug> #include <algorithm> +#include <cstdio> /* An implementation of AniList's "fuzzy date" */ @@ -21,6 +22,22 @@ SetDay(d); } +Date::Date(const std::string& str) { + unsigned int y, m, d; + + /* I don't like this that much, but it works... */ + int amt = std::sscanf(str.c_str(), "%4u-%2u-%2u", &y, &m, &d); + + if (amt > 0) + SetYear(y); + + if (amt > 1) + SetMonth(static_cast<Date::Month>(m - 1)); + + if (amt > 2) + SetDay(d); +} + Date::Date(const QDate& date) { SetYear(date.year()); auto m = date.month();