From b94bef381946e22fd1038f24e6d9de911d194640 Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期三, 31 七月 2024 23:33:48 +0800
Subject: [PATCH] 功能修改,工资计算调整,通过前端配置公式进行计算

---
 utils/timex.go |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/utils/timex.go b/utils/timex.go
index 230c96e..98ca7b1 100644
--- a/utils/timex.go
+++ b/utils/timex.go
@@ -17,3 +17,26 @@
 
 	return true
 }
+
+func GetMonthByOffset(offset int) time.Time {
+	return time.Now().AddDate(0, offset, 0)
+}
+
+// GetLastMonthPeriod 杩斿洖涓婁釜鏈堢殑鏈堝垵鏃堕棿鍜屾湀鏈椂闂�
+func GetLastMonthPeriod(now time.Time) (firstDay time.Time, lastDay time.Time) {
+	// 鑾峰彇鏈釜鏈堢殑绗竴澶╃殑鏃ユ湡锛堝嵆鏈湀鏈堝垵锛�
+	firstDayOfThisMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
+
+	nextMonth := now.AddDate(0, 1, 0)
+	// 鑾峰彇涓嬫湀绗竴澶╃殑鏃ユ湡锛堝嵆涓嬩釜鏈堟湀鍒濓級
+	firstDayOfNextMonth := time.Date(nextMonth.Year(), nextMonth.Month(), 1, 0, 0, 0, 0, now.Location())
+
+	// 涓嬩釜鏈堟湀鏈椂闂村嵆涓烘湰鏈堟湀鍒濆噺鍘讳竴绉�
+	lastDayOfThisMonth := firstDayOfNextMonth.Add(-time.Second)
+
+	return firstDayOfThisMonth, lastDayOfThisMonth
+}
+
+func GetMonthDuration(d time.Time) (duration int) {
+	return d.AddDate(0, 1, -1).Day()
+}

--
Gitblit v1.8.0