1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
void addDays(int d1, int m1, int y1, int x)
{
int offset1 = offsetDays(d1, m1, y1);
int remDays = isLeap(y1) ? (366 - offset1) : (365 - offset1);
int y2, offset2;
if (x <= remDays)
{
y2 = y1;
offset2 = offset1 + x;
}
else
{
x -= remDays;
y2 = y1 + 1;
int y2days = isLeap(y2) ? 366 : 365;
while (x >= y2days)
{
x -= y2days;
y2++;
y2days = isLeap(y2) ? 366 : 365;
}
offset2 = x;
}
int m2, d2;
revoffsetDays(offset2, y2, &d2, &m2);
textBox29->Text += d2 + " - " + m2 + " - " + y2;
}
int main()
{
int d = 1, m = 1, y = 1970;
int x = day;
addDays(d, m, y, x);
}
| |