Browse Source

修正时区

boweniac 4 days ago
parent
commit
6f4f3ac579
1 changed files with 3 additions and 1 deletions
  1. 3 1
      crontask/contact_form.go

+ 3 - 1
crontask/contact_form.go

@@ -131,7 +131,9 @@ func (l *CronTask) analyze() {
 	predicates = append(predicates, usagedetail.AppIn(1, 3, 4, 5))
 	//yesterdayStart := time.Now().AddDate(0, 0, -1).Truncate(24 * time.Hour)
 	//yesterdayEnd := yesterdayStart.Add(24 * time.Hour)
-	yesterdayEnd := time.Now().Truncate(24 * time.Hour)
+	loc, _ := time.LoadLocation("Asia/Shanghai")
+	now := time.Now().In(loc)
+	yesterdayEnd := now.Truncate(24 * time.Hour)
 	yesterdayStart := yesterdayEnd.AddDate(0, 0, -1)
 	predicates = append(predicates, usagedetail.CreatedAtGTE(yesterdayStart))
 	predicates = append(predicates, usagedetail.CreatedAtLT(yesterdayEnd))