-
Notifications
You must be signed in to change notification settings - Fork 3
/
zodiac.go
154 lines (149 loc) · 3.19 KB
/
zodiac.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package gozodiac
import "time"
// ZodiacSign represents the zodiac signs
type ZodiacSign int
func (s ZodiacSign) String() string {
switch s {
case Aries:
return "Aries"
case Taurus:
return "Taurus"
case Gemini:
return "Gemini"
case Cancer:
return "Cancer"
case Leo:
return "Leo"
case Virgo:
return "Virgo"
case Libra:
return "Libra"
case Scorpio:
return "Scorpio"
case Sagittarius:
return "Sagittarius"
case Capricorn:
return "Capricorn"
case Aquarius:
return "Aquarius"
case Pisces:
return "Pisces"
}
return ""
}
const (
// Aries zodiac sign
Aries ZodiacSign = iota
// Taurus zodiac sign
Taurus
// Gemini zodiac sign
Gemini
// Cancer zodiac sign
Cancer
// Leo zodiac sign
Leo
// Virgo zodiac sign
Virgo
// Libra zodiac sign
Libra
// Scorpio zodiac sign
Scorpio
// Sagittarius zodiac sign
Sagittarius
// Capricorn zodiac sign
Capricorn
// Aquarius zodiac sign
Aquarius
// Pisces zodiac sign
Pisces
)
// GetZodiacSign returns the matching zodiac sign
func GetZodiacSign(date time.Time) []ZodiacSign {
switch date.Month() {
case time.March:
if date.Day() < 20 {
return []ZodiacSign{Pisces}
} else if date.Day() == 20 {
return []ZodiacSign{Pisces, Aries}
}
return []ZodiacSign{Aries}
case time.April:
if date.Day() < 19 {
return []ZodiacSign{Aries}
} else if date.Day() == 19 {
return []ZodiacSign{Aries, Taurus}
}
return []ZodiacSign{Taurus}
case time.May:
if date.Day() < 20 {
return []ZodiacSign{Taurus}
} else if date.Day() == 20 {
return []ZodiacSign{Taurus, Gemini}
}
return []ZodiacSign{Gemini}
case time.June:
if date.Day() < 21 {
return []ZodiacSign{Gemini}
} else if date.Day() == 21 {
return []ZodiacSign{Gemini, Cancer}
}
return []ZodiacSign{Cancer}
case time.July:
if date.Day() < 22 {
return []ZodiacSign{Cancer}
} else if date.Day() == 22 {
return []ZodiacSign{Cancer, Leo}
}
return []ZodiacSign{Leo}
case time.August:
if date.Day() < 22 {
return []ZodiacSign{Leo}
} else if date.Day() == 22 {
return []ZodiacSign{Leo, Virgo}
}
return []ZodiacSign{Virgo}
case time.September:
if date.Day() < 22 {
return []ZodiacSign{Virgo}
} else if date.Day() == 22 {
return []ZodiacSign{Virgo, Libra}
}
return []ZodiacSign{Libra}
case time.October:
if date.Day() < 23 {
return []ZodiacSign{Libra}
} else if date.Day() == 23 {
return []ZodiacSign{Libra, Scorpio}
}
return []ZodiacSign{Scorpio}
case time.November:
if date.Day() < 22 {
return []ZodiacSign{Scorpio}
} else if date.Day() == 22 {
return []ZodiacSign{Scorpio, Sagittarius}
}
return []ZodiacSign{Sagittarius}
case time.December:
if date.Day() < 21 {
return []ZodiacSign{Sagittarius}
} else if date.Day() == 21 {
return []ZodiacSign{Sagittarius, Capricorn}
}
return []ZodiacSign{Capricorn}
case time.January:
if date.Day() < 20 {
return []ZodiacSign{Capricorn}
} else if date.Day() == 20 {
return []ZodiacSign{Capricorn, Aquarius}
}
return []ZodiacSign{Aquarius}
case time.February:
if date.Day() < 18 {
return []ZodiacSign{Aquarius}
} else if date.Day() == 18 {
return []ZodiacSign{Aquarius, Pisces}
}
return []ZodiacSign{Pisces}
}
return []ZodiacSign{Pisces}
}