From 9e864a183115ba2420797a8bda661187b1069e00 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期二, 23 四月 2024 11:46:41 +0800
Subject: [PATCH] 考勤统计与车间修改

---
 pkg/timex/timex.go |   41 ++++++++++++++++-------------------------
 1 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/pkg/timex/timex.go b/pkg/timex/timex.go
index 58ae6b0..e07e2f9 100644
--- a/pkg/timex/timex.go
+++ b/pkg/timex/timex.go
@@ -1,7 +1,6 @@
 package timex
 
 import (
-	"silkserver/constvar"
 	"time"
 )
 
@@ -58,29 +57,21 @@
 	return time.Now().Format(timeLayout)
 }
 
-func NextDateTimestamp(base time.Time, unit constvar.InspectCycleUnit, cycle int) time.Time {
-	var t time.Time
-	switch unit {
-	case constvar.InspectCycleUnitWeek:
-		t = base.AddDate(0, 0, cycle*7)
-	case constvar.InspectCycleUnitMonth:
-		t = base.AddDate(0, cycle, 0)
-	case constvar.InspectCycleUnitDay:
-		t = base.AddDate(0, 0, cycle)
+func GetDate(year int, month time.Month) int {
+	day := 0
+	if month == time.February {
+		if (year%4 == 0 && year%100 != 0) || year%400 == 0 {
+			day = 29
+		} else {
+			day = 28
+		}
+	} else {
+		if month == time.January || month == time.March || month == time.May || month == time.July ||
+			month == time.August || month == time.October || month == time.December {
+			day = 31
+		} else {
+			day = 30
+		}
 	}
-	return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
-}
-
-// Cycle2Seconds 鍛ㄦ湡鎹㈢畻鎴愮鏁�
-func Cycle2Seconds(unit constvar.InspectCycleUnit, cycle int) int {
-	var s int
-	switch unit {
-	case constvar.InspectCycleUnitWeek:
-		s = cycle * 86400 * 7
-	case constvar.InspectCycleUnitMonth:
-		s = cycle * 86400 * 30
-	case constvar.InspectCycleUnitDay:
-		s = cycle * 86400
-	}
-	return s
+	return day
 }

--
Gitblit v1.8.0