Browse Source

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

baoziqiang 2 months ago
parent
commit
f1abc31ee2
2 changed files with 6 additions and 1 deletions
  1. 5 1
      utils/common.go
  2. 1 0
      utils/constants.go

+ 5 - 1
utils/common.go

@@ -1066,7 +1066,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

@@ -8,6 +8,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