From 260b3fbc34b4e9ae2ee53e4a7917abb72ef848a7 Mon Sep 17 00:00:00 2001 From: dsmzx <dsmzx@123.com> Date: 星期二, 02 七月 2024 15:44:15 +0800 Subject: [PATCH] 出库/入库打印 修改bug --- utils/util.go | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/utils/util.go b/utils/util.go index 61c9c1c..c1b4d52 100644 --- a/utils/util.go +++ b/utils/util.go @@ -3,9 +3,31 @@ import ( "github.com/google/uuid" "strings" + "time" ) func GetUUID() string { s := uuid.New().String() return strings.ReplaceAll(s, "-", "") } + +// GetLastMonthPeriod 杩斿洖涓婁釜鏈堢殑鏈堝垵鏃堕棿鍜屾湀鏈椂闂� +func GetLastMonthPeriod() (time.Time, time.Time) { + // 鑾峰彇褰撳墠鏃堕棿 + now := time.Now() + + // 璁$畻涓婁釜鏈堢殑骞翠唤鍜屾湀浠� + lastMonth := now.AddDate(0, -1, 0) + lastYear, lastMonthNum, _ := lastMonth.Date() + + // 鑾峰彇涓婁釜鏈堢殑绗竴澶╃殑鏃ユ湡锛堝嵆涓婁釜鏈堟湀鍒濓級 + firstDayOfLastMonth := time.Date(lastYear, lastMonthNum, 1, 0, 0, 0, 0, now.Location()) + + // 鑾峰彇鏈湀绗竴澶╃殑鏃ユ湡锛堝嵆鏈湀鏈堝垵锛� + firstDayOfThisMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location()) + + // 涓婁釜鏈堟湀鏈椂闂村嵆涓烘湰鏈堟湀鍒濆噺鍘讳竴绉� + lastDayOfLastMonth := firstDayOfThisMonth.Add(-time.Second) + + return firstDayOfLastMonth, lastDayOfLastMonth +} -- Gitblit v1.8.0