Coder Social home page Coder Social logo

bazigo's Issues

农历日期计算有点问题?例如:1993年的。同好交流。

寿星万年历查询结果:
1993年11月13日
癸酉年 九月大 三十日
程序测试 bazi.LunarDate是{1993 10 30 21 10 0 0}。

之前想翻译个Go版的寿星万年历算法,放弃了。
八字,五行强度计算我也写了。加个微信共同交流一下,LongZhou588。

1月份的日期会触发panic

比如 bazi.GetBazi(1995, 1, 20, 7, 0, 0, 1),会触发panic
goroutine 1 [running]:
github.com/warrially/BaziGo.(*TLunarDate).GetAllDays(...)
/go/pkg/mod/github.com/warrially/[email protected]/lunardate.go:903
github.com/warrially/BaziGo.(*TLunarDate).Get64TimeStamp(...)
/go/pkg/mod/github.com/warrially/[email protected]/lunardate.go:387
github.com/warrially/BaziGo.(*TLunarDate).GetMonthFrom64TimeStamp(0xc00016e000, 0xea6b54af0)
/go/pkg/mod/github.com/warrially/[email protected]/lunardate.go:358 +0x85
github.com/warrially/BaziGo.NewLunarDateFrom64TimeStamp(0xc0001301b0?)
/go/pkg/mod/github.com/warrially/[email protected]/lunardate.go:58 +0x3d
github.com/warrially/BaziGo.(*TSolarDate).ToLunarDate(0x1153700?)
/go/pkg/mod/github.com/warrially/[email protected]/solardate.go:328 +0x18
github.com/warrially/BaziGo.(*TBazi).init(0xc0001522c0)
/go/pkg/mod/github.com/warrially/[email protected]/bazi.go:58 +0x6b

有内存泄露的问题

代码如下
func bz(t time.Time) string {
pBazi := bazi.GetBazi(t.Year(), int(t.Month()), t.Day(), t.Hour(), t.Minute(), t.Second(), 0)
sz := pBazi.SiZhu()
s := sz.YearZhu().GanZhi().ToString() + sz.MonthZhu().GanZhi().ToString() + sz.DayZhu().GanZhi().ToString() + sz.HourZhu().GanZhi().ToString()
return s
}

begin := time.Date(1931, 9, 18, 0, 0, 0, 0, time.Local)
end := time.Date(2020, 1, 1, 0, 0, 0, 0, time.Local)

for t := begin; end.After(t); t = t.AddDate(0, 1, 0) {
	println(t.Format("2006-01-02 15:04:05"), bz(t))
}

出现如下错误
PS D:\lab\go\bazi> go run .\main.go
1931-09-18 00:00:00
1931-09-18 00:00:00 辛未丁酉丙子戊子
1931-10-18 00:00:00 辛未戊戌丙午戊子
1931-11-18 00:00:00 辛未己亥丁丑庚子
1931-12-18 00:00:00 辛未庚子丁未庚子
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0xac8caa]

goroutine 1 [running]:
github.com/warrially/BaziGo.(*TLunarDate).GetAllDays(...)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/lunardate.go:851
github.com/warrially/BaziGo.(*TLunarDate).Get64TimeStamp(...)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/lunardate.go:335
github.com/warrially/BaziGo.(*TLunarDate).GetMonthFrom64TimeStamp(0xc000052050, 0xe30318100)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/lunardate.go:306 +0xaa
github.com/warrially/BaziGo.NewLunarDateFrom64TimeStamp(0xe30318100, 0xe30318100)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/lunardate.go:60 +0x6d
github.com/warrially/BaziGo.(*TSolarDate).ToLunarDate(0xc000050a50, 0xfe7540)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/solardate.go:328 +0x45
github.com/warrially/BaziGo.(*TBazi).init(0xc00001a780, 0xc00001a780)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/bazi.go:59 +0x2b5
github.com/warrially/BaziGo.NewBazi(...)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/bazi.go:12
github.com/warrially/BaziGo.GetBazi(0x78c, 0x1, 0x12, 0x0, 0x0, 0x0, 0x0, 0x11)
d:/dev/gopath/pkg/mod/github.com/warrially/[email protected]/bazi.go:33 +0xb2
main.bz(0x0, 0xe302d1c00, 0xfe6c00, 0xb2de88, 0x13)
D:/lab/go/bazi/main.go:19 +0x26d
main.main()
D:/lab/go/bazi/main.go:57 +0x205
exit status 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.