-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchinese.go
125 lines (94 loc) · 2.01 KB
/
chinese.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
package gozodiacs
// Only require system time module.
import "time"
// ChineseZodiacSign represents the chinese zodiac signs based on the year of a persons birth. - https://en.wikipedia.org/wiki/Chinese_zodiac
type ChineseZodiacSign int
// The "Chinese" zodiac sign as a simple name string.
func (s ChineseZodiacSign) String() string {
switch s {
case Monkey:
return "Monkey"
case Rooster:
return "Rooster"
case Dog:
return "Dog"
case Pig:
return "Pig"
case Rat:
return "Rat"
case Ox:
return "Ox"
case Tiger:
return "Tiger"
case Rabbit:
return "Rabbit"
case Dragon:
return "Dragon"
case Snake:
return "Snake"
case Horse:
return "Horse"
}
// case Goat:
return "Goat"
}
// Chinese Zodiac Signs as Constants
const (
// Monkey chinese zodiac sign
Monkey ChineseZodiacSign = iota
// Rooster chinese zodiac sign
Rooster
// Dog chinese zodiac sign
Dog
// Pig chinese zodiac sign
Pig
// Rat chinese zodiac sign
Rat
// Ox chinese zodiac sign
Ox
// Tiger chinese zodiac sign
Tiger
// Rabbit chinese zodiac sign
Rabbit
// Dragon chinese zodiac sign
Dragon
// Snake chinese zodiac sign
Snake
// Horse chinese zodiac sign
Horse
// Goat chinese zodiac sign
Goat
)
// GetAllChineseZodiacSigns - Return a new list of all possible chinese zodiac sign constants in sequence. Used for UI/etc.
func GetAllChineseZodiacSigns() []ChineseZodiacSign {
return []ChineseZodiacSign{Monkey, Rooster, Dog, Pig, Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat}
}
// GetChineseZodiacSign returns the single matching chinese zodiac sign based on the year given.
func GetChineseZodiacSign(date time.Time) ChineseZodiacSign {
chineseZodiac := int(date.Year() - ((date.Year() / 12) * 12))
switch chineseZodiac {
case 0:
return Monkey
case 1:
return Rooster
case 2:
return Dog
case 3:
return Pig
case 4:
return Rat
case 5:
return Ox
case 6:
return Tiger
case 7:
return Rabbit
case 8:
return Dragon
case 9:
return Snake
case 10:
return Horse
}
return Goat
}