//Return the day of the week from an entered date.
//By DreamVB
#include <iostream>

using namespace std;
using std::cout;
using std::endl;

string DayOfWeek(int iDay, int iMonth, int iYear, bool ShortName = false)
{
	int iValue = 0;
	string Ret = "";
	//Long day names.
	string Days[] = { "Sunday", "Monday", "Tuesday", 
		"Wednesday", "Thursday", "Friday", "Saturday" };

	if (iMonth <= 2)
	{
		iMonth = (iMonth + 12);
		iYear = (iYear - 1);
	}

	iValue = (iDay + iMonth * 2);
	iValue += (((iMonth + 1) * 6) / 10);
	iValue += (iYear + iYear / 4 - iYear / 100);
	iValue += (iYear / 400 + 2);
	iValue %= 7;
	//Extract day
	Ret = Days[((iValue ? iValue : 7) - 1)];

	if (ShortName){
		//Return short day name
		return Ret.substr(0, 3);
	}
	//Return long day name.
	return Ret;
}

int main(int argc, char *argv[]){
	//Print long day out
	cout << "Long Day of week for 2/10/2016 ";
	cout << DayOfWeek(2, 9, 2016).c_str() << endl;
	//Print short day name
	cout << "Short Day of week for 2/10/2016 ";
	cout << DayOfWeek(2, 9, 2016, true).c_str() << endl;

	system("pause");
	return 0;
}