瀏覽代碼

Merge branch 'bzq/history_chart_range' of eta_gn_server/eta_chart_lib into master

baoziqiang 4 月之前
父節點
當前提交
c7cf6e9ba1
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 5 1
      utils/common.go
  2. 1 0
      utils/constants.go

+ 5 - 1
utils/common.go

@@ -1033,7 +1033,11 @@ func GetDateByDateTypeV2(dateType int, tmpStartDate, tmpEndDate string, startYea
 			startDate = startDate + "-01"
 		}
 		if strings.Count(endDate, "-") == 1 {
-			endDate = endDate + "-01"
+			endTime, err := time.Parse(FormatYearMonthDate, endDate)
+			if err != nil {
+				return
+			}
+			endDate = endTime.AddDate(0, 1, -1).Format(FormatDate)
 		}
 	}
 

+ 1 - 0
utils/constants.go

@@ -9,6 +9,7 @@ const (
 	FormatDateTime        = "2006-01-02 15:04:05"       //完整时间格式
 	HlbFormatDateTime     = "2006-01-02_15:04:05.999"   //完整时间格式
 	FormatDateTimeUnSpace = "20060102150405"            //完整时间格式
+	FormatYearMonthDate   = "2006-01"                   //日期格式
 	PageSize15            = 15                          //列表页每页数据量
 	PageSize5             = 5
 	PageSize10            = 10