|
@@ -168,13 +168,14 @@ func GetTimeRange(s string) map[string]int64 { |
|
|
// 明天 0点 |
|
|
// 明天 0点 |
|
|
etime = time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, 0, t.Location()) |
|
|
etime = time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, 0, t.Location()) |
|
|
case "current_month": |
|
|
case "current_month": |
|
|
stime = time.Date(t.Year(), t.Month(), 0, 0, 0, 0, 0, t.Location()) |
|
|
|
|
|
etime = time.Date(t.Year(), t.Month()+1, 0, 0, 0, 0, 0, t.Location()) |
|
|
|
|
|
|
|
|
stime = GetFirstDateOfMonth(t) |
|
|
|
|
|
etime = time.Now() |
|
|
case "last_month": |
|
|
case "last_month": |
|
|
stime = time.Date(t.Year(), t.Month()-1, 0, 0, 0, 0, 0, t.Location()) |
|
|
|
|
|
etime = time.Date(t.Year(), t.Month(), 0, 0, 0, 0, 0, t.Location()) |
|
|
|
|
|
|
|
|
etime = GetFirstDateOfMonth(t) |
|
|
|
|
|
monthTimes := TimeStdParseUnix(etime.Format("2006-01-02 15:04:05")) - 86400 |
|
|
|
|
|
times, _ := UnixToTime(Int64ToStr(monthTimes)) |
|
|
|
|
|
stime = GetFirstDateOfMonth(times) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return map[string]int64{ |
|
|
return map[string]int64{ |
|
|
"start": stime.Unix(), |
|
|
"start": stime.Unix(), |
|
|
"end": etime.Unix(), |
|
|
"end": etime.Unix(), |
|
@@ -215,6 +216,13 @@ func GetFirstDateOfMonth(d time.Time) time.Time { |
|
|
return GetZeroTime(d) |
|
|
return GetZeroTime(d) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//时间戳转时间格式 |
|
|
|
|
|
func UnixToTime(e string) (datatime time.Time, err error) { |
|
|
|
|
|
data, err := strconv.ParseInt(e, 10, 64) |
|
|
|
|
|
datatime = time.Unix(data, 0) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。 |
|
|
//获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。 |
|
|
func GetLastDateOfMonth(d time.Time) time.Time { |
|
|
func GetLastDateOfMonth(d time.Time) time.Time { |
|
|
return GetFirstDateOfMonth(d).AddDate(0, 1, -1) |
|
|
return GetFirstDateOfMonth(d).AddDate(0, 1, -1) |
|
|