Calculating Yesterday's Date

Hey guys, quick question. I have a program I am writing that is supposed to calculate tomorrow's date and yesterday's date. I have tomorrow figured out, but I need help with yesterday. Here is the code from tomorrow();
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
39
40
41
42
43
44
45
46
 void Date::tomorrow()
{
	{
	int m = month, d = day, y = year;

	switch(m)


	{case 1: case 3: case 5: case 7: case 8: case 10: case 12:
		if(d < 30)
		{d ++; break;}

		else if((d <= 31) && (m < 11))
		{m ++;d = 1;break;}

		else if((d <= 31) && (m >= 12))
		{y ++;m = 1;d = 1;break;}


	case 4: case 6: case 9: case 11:
		if(d < 29)
		{d ++;break;}

		else if(d <= 30)
		{m ++;d = 1;break;
		}


	case 2: //February
		if((leapyear(y)) && (d < 29))
		{d ++;break;}

		else if((!(leapyear(y))) && (d < 28))
		{d ++;break;}

		else if((leapyear(y)) && (d >= 29))
		{m ++;d = 1;break;}

		else if ((!(leapyear(y))) && (d >= 28))
		{m ++; d = 1; break;}


	}
	cout << m << "-" << d << "-" << y << endl;
	}
}
Topic archived. No new replies allowed.