#include<iostream>
#include"Date.h"

using namespace std;

int main()
{
	/*Testing the constructors*/
	

	//default constructor
	Date d1;
	d1.printVerbose();

	//constructor taking three integers as input
	Date d2(3,4,1990);//constructor taking three integers as input
	d2.printVerbose();

	
	string date;
	cout<<"Input date in format m/d/yyyy: ";
	cin>>date;

	//constructor taking a date string m/d/yyyy as input
	Date d3(date);
	d3.printVerbose();

	Date d6(d3);
	d6.printVerbose();

	Date *dtPtr=new Date(5,7,2009);
	dtPtr->printVerbose();

	dtPtr=&d3;

	dtPtr->printVerbose();

	

	//testing the pre-increment operator
	cout<<"\n\nTesting the pre-increment operator";
	cout<<"\nThe day after ";
	d3.printVerbose();
	++d3;
	cout<<"is ";
	d3.printVerbose();

	/*testing the post-increment operator, 
	remark the d1 is first assigned the value of d2 and only after
	that is d2 incremented*/
	cout<<"\nTesting the post-increment operator: \n";
	d1=d2++;

	d1.printVerbose();
	d2.printVerbose();


	//testing the nextBusDay operator
	Date d4(2,4,2005);
	
	cout<<"\nThe next Business Day after \n";
	d4.printVerbose();
	d4.nextBusDay();
	cout<<"is ";
	d4.printVerbose();

	//testing the comparison operators
	cout<<"\n\nAre ";
	d2.printVerbose();
	cout<<"and ";
	d3.printVerbose();
	cout<<"the same date? ";
	cout<<((d1==d2)?"yes":"no")<<endl;
	cout<<"Is ";
	d1.printVerbose();
	cout<<"before ";
	d2.printVerbose();
	cout<<"? ";
	cout<<((d1<d2)?"yes":"no")<<endl;

	//testing the += operator
	cout<<"\nAdding 31 days to : ";
	d2.printVerbose();
	d2+=31;
	cout<<"is the date: ";
	d2.printVerbose();
	d2-=31;
	d2.printVerbose();
	d2-=100000;
	d2.printVerbose();

	//testing the decrement operator
	cout<<"\nThe day before \n";
	d3.printVerbose();
	cout<<"is: ";
	d3--;
	d3.printVerbose();

	//finding Friday the 13th
	
	Date dt1("1/31/2006");
	Date dt2("1/31/2005");
	

	cout<<"\n\nFinding all the Fridays the 13th between ";
	dt2.printVerbose();
	cout<<"and ";
	dt1.printVerbose();
	cout<<"\n\n";

	for(int i=dt2.daysSinceStart();i<=dt1.daysSinceStart();i++)
	{
		Date d=daysToDate(i);
		if( ( i % 7==5)&& d.getDay()==13)
		{

			d.printVerbose();
			cout<<"will be an unlucky day"<<endl;
		
	
		}
	}
	
	//code to make sure the window doesn't disappear right away
	cout<<"\n\nType Q to quit the program: ";
	char quit;
		while((quit=cin.get())!='Q');
	return 0;


}
