|
@@ -1046,4 +1046,25 @@ func GetWeekZn(updateWeek string) (week string) {
|
|
|
week = "周日"
|
|
|
}
|
|
|
return week
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+func GetWeekDay() (string, string) {
|
|
|
+ now := time.Now()
|
|
|
+ offset := int(time.Monday - now.Weekday())
|
|
|
+ //周日做特殊判断 因为time.Monday = 0
|
|
|
+ if offset > 0 {
|
|
|
+ offset = -6
|
|
|
+ }
|
|
|
+
|
|
|
+ lastoffset := int(time.Saturday - now.Weekday())
|
|
|
+ //周日做特殊判断 因为time.Monday = 0
|
|
|
+ if lastoffset == 6 {
|
|
|
+ lastoffset = -1
|
|
|
+ }
|
|
|
+
|
|
|
+ firstOfWeek := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
|
|
|
+ lastOfWeeK := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, lastoffset+1)
|
|
|
+ f := firstOfWeek.Unix()
|
|
|
+ l := lastOfWeeK.Unix()
|
|
|
+ return time.Unix(f, 0).Format("2006-01-02") + " 00:00:00", time.Unix(l, 0).Format("2006-01-02") + " 23:59:59"
|
|
|
+}
|