-
Notifications
You must be signed in to change notification settings - Fork 0
/
getZodiac.html
51 lines (49 loc) · 1.73 KB
/
getZodiac.html
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
47
48
49
50
51
<div id='output'></div>
<script>
// ================== getZodiac function begins ===============================
function getZodiac(month, day){
var datecode = month*100 + day; //this will give us a number represent month and day
if (datecode <= 120){ // Jan 20
return "Capricorn";
}else if (datecode <= 219) { // Feb 19
return "Aquarius";
}else if (datecode <= 320) { // Mar 20
return "Pisces";
}else if (datecode <= 420) { // Apr 20
return "Aries";
}else if (datecode <= 520) { // May 20
return "Taurus";
}else if (datecode <= 621) { // Jun 21
return "Gemini";
}else if (datecode <= 722) { // Jul 22
return "Cancer";
}else if (datecode <= 822) { // Aug 22 -- Wikipedia says that it's Aug 23 but then
// but then it starts again with Aug 23 so I
// don't know what's up with that.
return "Leo";
}else if (datecode <= 921) { // Sept 21
return "Virgo";
}else if (datecode <= 1022) { // Oct 22
return "Libra";
}else if (datecode <= 1121) { // Nov 21
return "Scorpio";
}else if (datecode <= 1221) { // Dec 21
return "Sagittarius";
}else{ //if we hit this case it means we hava greater date code than Dec 21
return "Capricorn";
}
}
// ================== getZodiac function ends =================================
// Test code below ============================================================
output = "";
for (var i=0;i<366;i++){
date = new Date();
date.setDate((new Date()).getDate()+i);
year = date.getFullYear();
month = date.getMonth()+1;
day = date.getDate();
dateDisplay = year + "/"+month+"/"+day;
output += dateDisplay + " => "+ getZodiac(month,day) + "<br/>";
}
document.getElementById("output").innerHTML = output;
</script>