Skip to content

Commit

Permalink
update chronos
Browse files Browse the repository at this point in the history
  • Loading branch information
godcong committed Nov 8, 2019
1 parent d19b349 commit 3a0339d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lunar.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Lunar struct {
hour int
leapMonth int
leap bool
fixLiChun int //立春当天如果未到时辰:-1
}

var loc *time.Location
Expand All @@ -35,6 +36,10 @@ func (lunar *Lunar) Type() string {
return "lunar"
}

func (lunar *Lunar) FixLiChun(fix int) {
lunar.fixLiChun = fix
}

// Calendar ...
func (lunar *Lunar) Calendar() Calendar {
t := time.Time{}
Expand All @@ -43,12 +48,8 @@ func (lunar *Lunar) Calendar() Calendar {
}

// EightCharacter ...
func (lunar *Lunar) EightCharacter(fix ...int) []string {
rlt := lunar.nianZhu(0)
if fix != nil {
rlt = lunar.nianZhu(fix[0])
}
rlt += lunar.yueZhu() + lunar.riZhu() + lunar.shiZhu()
func (lunar *Lunar) EightCharacter() []string {
rlt := lunar.nianZhu(lunar.fixLiChun) + lunar.yueZhu() + lunar.riZhu() + lunar.shiZhu()
return strings.Split(rlt, "")
}

Expand Down Expand Up @@ -78,7 +79,7 @@ func (lunar *Lunar) nianZhu(fix int) string {

// GetZodiac ...
func GetZodiac(lunar *Lunar) string {
s := string([]rune(lunar.nianZhu())[1])
s := string([]rune(lunar.nianZhu(lunar.fixLiChun))[1])
for idx, v := range earthyBranch {
if strings.Compare(v, s) == 0 {
return zodiacs[idx]
Expand Down

0 comments on commit 3a0339d

Please sign in to comment.