Skip to content

Instantly share code, notes, and snippets.

@GlowingAshes
Last active January 30, 2017 07:03
Show Gist options
  • Save GlowingAshes/8b2345f5177513ed57615a98347ed6ed to your computer and use it in GitHub Desktop.
Save GlowingAshes/8b2345f5177513ed57615a98347ed6ed to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
int userDay = 0;
int userYear = 0;
int userMonth = 0;
int day = 0;
int h = 0;
int q = 0;
int m = 0;
int k = 0;
int j = 0;
string Day = "";
cin >> userYear;
cin >> userMonth;
cin >> userDay;
userMonth = userMonth *-1;
userDay = userDay *-1;
//cout << "Please enter a date in numbers: " << endl;
//cout << "Year: " << endl;
//cin >> userYear;
//cout << "Month: " << endl;
//cin >> userMonth;
//cout << "Day: " << endl;
//cin >> userDay;
if (userMonth == 1) {
userMonth = 13;
userYear -= 1;
}
if (userMonth == 2) {
userMonth = 14;
userYear -= 1;
}
h = day;
q = userDay;
m = userMonth;
k = userYear % 100;
j = userYear/100;
h = (q + ((13*(m+1))/5)+k+(k/4)+(j/4)+(5*j)) % 7;
//day = (userDay + ((13 * (userMonth + 1)) / 5) + (userYear % 100) + ((userYear % 100)/4) + ((userYear/100)/4) +(5*(userYear/100))) % 7;
//day = static_cast<int>(userDay + ((13*(userMonth+1))/5) + userYear + (userYear/4) - (userYear/100) + (userYear/400)) % 7;
switch (h) {
case 0:
Day = "Sabbath";
break;
case 1:
Day = "Sunday";
break;
case 2:
Day = "Monday";
break;
case 3:
Day = "Tuesday";
break;
case 4:
Day = "Wednesday";
break;
case 5:
Day = "Thursday";
break;
case 6:
Day = "Friday";
break;
}
cout << "The day of the week that your date falls on is " << Day << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment