comparison 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
comparison
equal deleted inserted replaced
316:180714442770 317:b1f4d1867ab1
3 3
4 #include <QDate> 4 #include <QDate>
5 #include <QDebug> 5 #include <QDebug>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdio>
8 9
9 /* An implementation of AniList's "fuzzy date" */ 10 /* An implementation of AniList's "fuzzy date" */
10 11
11 Date::Date() { 12 Date::Date() {
12 } 13 }
17 18
18 Date::Date(Date::Year y, Date::Month m, Date::Day d) { 19 Date::Date(Date::Year y, Date::Month m, Date::Day d) {
19 SetYear(y); 20 SetYear(y);
20 SetMonth(m); 21 SetMonth(m);
21 SetDay(d); 22 SetDay(d);
23 }
24
25 Date::Date(const std::string& str) {
26 unsigned int y, m, d;
27
28 /* I don't like this that much, but it works... */
29 int amt = std::sscanf(str.c_str(), "%4u-%2u-%2u", &y, &m, &d);
30
31 if (amt > 0)
32 SetYear(y);
33
34 if (amt > 1)
35 SetMonth(static_cast<Date::Month>(m - 1));
36
37 if (amt > 2)
38 SetDay(d);
22 } 39 }
23 40
24 Date::Date(const QDate& date) { 41 Date::Date(const QDate& date) {
25 SetYear(date.year()); 42 SetYear(date.year());
26 auto m = date.month(); 43 auto m = date.month();