|
@@ -1101,3 +1101,54 @@ func TimeTransferString(format string, t time.Time) string {
|
|
|
}
|
|
|
return str
|
|
|
}
|
|
|
+
|
|
|
+// GetDateByDateType 通过dateType获取需要的开始/结束日期
|
|
|
+func GetDateByDateType(dateType int, tmpStartDate, tmpEndDate string) (startDate, endDate string) {
|
|
|
+ startDate = tmpStartDate
|
|
|
+ endDate = tmpEndDate
|
|
|
+ switch dateType {
|
|
|
+ case 1:
|
|
|
+ startDate = "2000-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 2:
|
|
|
+ startDate = "2010-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 3:
|
|
|
+ startDate = "2015-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 4:
|
|
|
+ //startDate = strconv.Itoa(time.Now().Year()) + "-01-01"
|
|
|
+ startDate = "2021-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 5:
|
|
|
+ //startDate = startDate + "-01"
|
|
|
+ //endDate = endDate + "-01"
|
|
|
+ case 6:
|
|
|
+ //startDate = startDate + "-01"
|
|
|
+ endDate = ""
|
|
|
+ case 7:
|
|
|
+ startDate = "2018-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 8:
|
|
|
+ startDate = "2019-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 9:
|
|
|
+ startDate = "2020-01-01"
|
|
|
+ endDate = ""
|
|
|
+ case 11:
|
|
|
+ startDate = "2022-01-01"
|
|
|
+ endDate = ""
|
|
|
+ }
|
|
|
+
|
|
|
+ // 兼容日期错误
|
|
|
+ {
|
|
|
+ if strings.Count(startDate, "-") == 1 {
|
|
|
+ startDate = startDate + "-01"
|
|
|
+ }
|
|
|
+ if strings.Count(endDate, "-") == 1 {
|
|
|
+ endDate = endDate + "-01"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|