12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package models
- import (
- "eta_gn/eta_chart_lib/utils"
- "time"
- )
- func HandleDataByPreviousData(edbInfoDataList []*EdbDataList, handleDataMap map[string]float64) (err error) {
- if len(edbInfoDataList) < 2 {
- return
- }
- var startEdbInfoData *EdbDataList
- for _, v := range edbInfoDataList {
- handleDataMap[v.DataTime] = v.Value
- if startEdbInfoData == nil {
- startEdbInfoData = v
- continue
- }
- startDataTime, _ := time.ParseInLocation(utils.FormatDate, startEdbInfoData.DataTime, time.Local)
- currDataTime, _ := time.ParseInLocation(utils.FormatDate, v.DataTime, time.Local)
- betweenHour := int(currDataTime.Sub(startDataTime).Hours())
- betweenDay := betweenHour / 24
- if betweenDay <= 1 {
- startEdbInfoData = v
- continue
- }
- {
- for i := 1; i < betweenDay; i++ {
- tmpDataTime := startDataTime.AddDate(0, 0, i)
- handleDataMap[tmpDataTime.Format(utils.FormatDate)] = startEdbInfoData.Value
- }
- }
- startEdbInfoData = v
- }
- return
- }
|