From 2e6b0e5e2e2b85e936c6b529dbbfaceef4891077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E7=BA=AF=E5=87=80?= <1113655791@qq.com> Date: Sat, 15 Mar 2025 15:06:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0(=E5=8E=86=E5=8F=B2)=E5=88=86?= =?UTF-8?q?=E6=97=B6=E5=9B=BE=E7=9A=84=E6=97=B6=E9=97=B4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?"15:00"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocol/model_minute.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/protocol/model_minute.go b/protocol/model_minute.go index ae60f43..fb47d8d 100644 --- a/protocol/model_minute.go +++ b/protocol/model_minute.go @@ -2,6 +2,8 @@ package protocol import ( "errors" + "fmt" + "time" ) type MinuteResp struct { @@ -10,10 +12,15 @@ type MinuteResp struct { } type PriceNumber struct { + Time string Price Price Number int } +func (this PriceNumber) String() string { + return fmt.Sprintf("%s \t%-6s \t%-6d(手)", this.Time, this.Price, this.Number) +} + type minute struct{} func (this *minute) Frame(code string) (*Frame, error) { @@ -43,12 +50,17 @@ func (this *minute) Decode(bs []byte) (*MinuteResp, error) { bs = bs[6:] price := Price(0) + t := time.Date(0, 0, 0, 9, 0, 0, 0, time.Local) for i := uint16(0); i < resp.Count; i++ { bs, price = GetPrice(bs) bs, _ = CutInt(bs) //这个是什么 var number int bs, number = CutInt(bs) + if i == 120 { + t = t.Add(time.Hour * 2) + } resp.List = append(resp.List, PriceNumber{ + Time: t.Add(time.Minute * time.Duration(i)).Format("15:04"), Price: price, Number: number, })