|
@ -21,18 +21,18 @@ func FormatDate(str string) string { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//获取当天开始时间戳
|
|
|
//获取当天开始时间戳
|
|
|
func GetTodayStartTimeStamp() int64{ |
|
|
|
|
|
|
|
|
func GetTodayStartTimeStamp() int64 { |
|
|
|
|
|
|
|
|
var reserveTime time.Time |
|
|
var reserveTime time.Time |
|
|
loc, _ := time.LoadLocation("Asia/Shanghai") |
|
|
loc, _ := time.LoadLocation("Asia/Shanghai") |
|
|
|
|
|
|
|
|
date := time.Now().Format("2006-01-02") |
|
|
date := time.Now().Format("2006-01-02") |
|
|
reserveTime,_ = time.ParseInLocation("2006-01-02",date,loc) |
|
|
|
|
|
|
|
|
reserveTime, _ = time.ParseInLocation("2006-01-02", date, loc) |
|
|
return reserveTime.Unix() |
|
|
return reserveTime.Unix() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//获取本周开始时间戳
|
|
|
//获取本周开始时间戳
|
|
|
func GetWeekStartTimeStamp() int64{ |
|
|
|
|
|
|
|
|
func GetWeekStartTimeStamp() int64 { |
|
|
|
|
|
|
|
|
var reserveTime time.Time |
|
|
var reserveTime time.Time |
|
|
now := time.Now() |
|
|
now := time.Now() |
|
@ -46,17 +46,36 @@ func GetWeekStartTimeStamp() int64{ |
|
|
weekStartDate := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) |
|
|
weekStartDate := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset) |
|
|
weekMonday := weekStartDate.Format("2006-01-02") |
|
|
weekMonday := weekStartDate.Format("2006-01-02") |
|
|
|
|
|
|
|
|
reserveTime,_ = time.ParseInLocation("2006-01-02",weekMonday,loc) |
|
|
|
|
|
|
|
|
reserveTime, _ = time.ParseInLocation("2006-01-02", weekMonday, loc) |
|
|
return reserveTime.Unix() |
|
|
return reserveTime.Unix() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//获取当月开始时间戳
|
|
|
//获取当月开始时间戳
|
|
|
func GetMonthStartTimeStamp() int64{ |
|
|
|
|
|
|
|
|
func GetMonthStartTimeStamp() int64 { |
|
|
|
|
|
|
|
|
var reserveTime time.Time |
|
|
var reserveTime time.Time |
|
|
loc, _ := time.LoadLocation("Asia/Shanghai") |
|
|
loc, _ := time.LoadLocation("Asia/Shanghai") |
|
|
|
|
|
|
|
|
date := time.Now().Format("2006-01") |
|
|
date := time.Now().Format("2006-01") |
|
|
reserveTime,_ = time.ParseInLocation("2006-01",date,loc) |
|
|
|
|
|
|
|
|
reserveTime, _ = time.ParseInLocation("2006-01", date, loc) |
|
|
return reserveTime.Unix() |
|
|
return reserveTime.Unix() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RFC3339ToCSTLayout convert rfc3339 value to china standard time layout
|
|
|
|
|
|
func RFC3339ToCSTLayout(value string) (string, error) { |
|
|
|
|
|
var ( |
|
|
|
|
|
cst *time.Location |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
if cst, err = time.LoadLocation("Asia/Shanghai"); err != nil { |
|
|
|
|
|
panic(err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ts, err := time.Parse(time.RFC3339, value) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ts.In(cst).Format("2006-01-02 15:04:05"), nil |
|
|
|
|
|
} |