1
0

wochentagsberechnung gefixed

This commit is contained in:
Joel Baldauf
2021-01-08 14:01:23 +01:00
parent 5932606560
commit d49965d367
+11 -6
View File
@@ -72,16 +72,18 @@ void datum::ausgeben() {
int datum::wochentag() int datum::wochentag()
{ {
string yearst = to_string(jahr); int year = jahr;
int m = monat;
if (m < 3)
year--;
string yearst = to_string(year);
string cst = yearst.substr(0, 2); string cst = yearst.substr(0, 2);
string yst = yearst.substr(2, 4); string yst = yearst.substr(2, 4);
int y = stoi(yst); int y = stoi(yst);
int c = stoi(cst); int c = stoi(cst);
int d = tag; int d = tag;
int m = monat;
if (m < 3)
y--;
if (m == 1 || m == 2) if (m == 1 || m == 2)
m += 10; m += 10;
@@ -118,8 +120,11 @@ int datum::kwBerechnen()
int offset = 0; int offset = 0;
int kw = 0; int kw = 0;
if (wochentagErste < 4) if (wochentagErste < 4) {
offset = wochentagErste - 2; offset = wochentagErste - 2;
kw += 1;
}
else else
offset = (8 - wochentagErste) % 7; offset = (8 - wochentagErste) % 7;