From 38493379199a786fc3eca83e03c5340135153d1f Mon Sep 17 00:00:00 2001 From: dudaodong Date: Mon, 31 Mar 2025 10:27:09 +0800 Subject: [PATCH] doc: update example link for BeginOfWeek and EndOfWeek --- README.md | 4 ++-- README_zh-CN.md | 4 ++-- datetime/datetime.go | 4 ++-- docs/api/packages/datetime.md | 2 +- docs/en/api/packages/datetime.md | 13 +++++++------ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index fc190ba..9699630 100644 --- a/README.md +++ b/README.md @@ -535,7 +535,7 @@ import "github.com/duke-git/lancet/v2/datetime" [[play](https://go.dev/play/p/94m_UT6cWs9)] - **BeginOfWeek** : return the date time at the begin of week of specific date. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#BeginOfWeek)] - [[play](https://go.dev/play/p/ynjoJPz7VNV)] + [[play](https://go.dev/play/p/DCHdcL6gnfV)] - **BeginOfMonth** : return the date time at the begin of month of specific date. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#BeginOfMonth)] [[play](https://go.dev/play/p/bWXVFsmmzwL)] @@ -553,7 +553,7 @@ import "github.com/duke-git/lancet/v2/datetime" [[play](https://go.dev/play/p/eMBOvmq5Ih1)] - **EndOfWeek** : return the date time at the end of week of specific date. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#EndOfWeek)] - [[play](https://go.dev/play/p/i08qKXD9flf)] + [[play](https://go.dev/play/p/mGSA162YgX9)] - **EndOfMonth** : return the date time at the end of month of specific date. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#EndOfMonth)] [[play](https://go.dev/play/p/_GWh10B3Nqi)] diff --git a/README_zh-CN.md b/README_zh-CN.md index 162cc4f..fbc72ab 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -536,7 +536,7 @@ import "github.com/duke-git/lancet/v2/datetime" [[play](https://go.dev/play/p/94m_UT6cWs9)] - **BeginOfWeek** : 返回指定时间的每周开始时间,默认开始时间星期日。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#BeginOfWeek)] - [[play](https://go.dev/play/p/ynjoJPz7VNV)] + [[play](https://go.dev/play/p/DCHdcL6gnfV)] - **BeginOfMonth** : 返回指定时间的当月开始时间。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#BeginOfMonth)] [[play](https://go.dev/play/p/bWXVFsmmzwL)] @@ -554,7 +554,7 @@ import "github.com/duke-git/lancet/v2/datetime" [[play](https://go.dev/play/p/eMBOvmq5Ih1)] - **EndOfWeek** : 返回指定时间的星期结束时间,默认结束时间星期六。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#EndOfWeek)] - [[play](https://go.dev/play/p/i08qKXD9flf)] + [[play](https://go.dev/play/p/mGSA162YgX9)] - **EndOfMonth** : 返回指定时间的月份结束时间。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#EndOfMonth)] [[play](https://go.dev/play/p/_GWh10B3Nqi)] diff --git a/datetime/datetime.go b/datetime/datetime.go index b2b303f..b4b687a 100644 --- a/datetime/datetime.go +++ b/datetime/datetime.go @@ -280,7 +280,7 @@ func EndOfDay(t time.Time) time.Time { } // BeginOfWeek return beginning week, default week begin from Sunday. -// Play: https://go.dev/play/p/ynjoJPz7VNV +// Play: https://go.dev/play/p/DCHdcL6gnfV func BeginOfWeek(t time.Time, beginFrom time.Weekday) time.Time { y, m, d := t.AddDate(0, 0, int(beginFrom-t.Weekday())).Date() beginOfWeek := time.Date(y, m, d, 0, 0, 0, 0, t.Location()) @@ -291,7 +291,7 @@ func BeginOfWeek(t time.Time, beginFrom time.Weekday) time.Time { } // EndOfWeek return end week time, default week end with Saturday. -// Play: https://go.dev/play/p/i08qKXD9flf +// Play: https://go.dev/play/p/mGSA162YgX9 func EndOfWeek(t time.Time, endWith time.Weekday) time.Time { y, m, d := t.AddDate(0, 0, int(endWith-t.Weekday())).Date() var endWithWeek = time.Date(y, m, d, 23, 59, 59, int(time.Second-time.Nanosecond), t.Location()) diff --git a/docs/api/packages/datetime.md b/docs/api/packages/datetime.md index 0010ae6..28c984d 100644 --- a/docs/api/packages/datetime.md +++ b/docs/api/packages/datetime.md @@ -741,7 +741,7 @@ func main() { func EndOfWeek(t time.Time, endWith time.Weekday) time.Time ``` -示例:[运行](https://go.dev/play/p/i08qKXD9flf) +示例:[运行](https://go.dev/play/p/mGSA162YgX9) ```go package main diff --git a/docs/en/api/packages/datetime.md b/docs/en/api/packages/datetime.md index db8b0f8..e5fc707 100644 --- a/docs/en/api/packages/datetime.md +++ b/docs/en/api/packages/datetime.md @@ -551,7 +551,7 @@ func main() { func BeginOfWeek(t time.Time, beginFrom ...time.Weekday) time.Time ``` -Example:[Run](https://go.dev/play/p/ynjoJPz7VNV) +Example:[Run](https://go.dev/play/p/DCHdcL6gnfV) ```go package main @@ -564,12 +564,13 @@ import ( func main() { input := time.Date(2023, 1, 8, 18, 50, 10, 100, time.UTC) - result := datetime.BeginOfWeek(input) + + result := datetime.BeginOfWeek(input, time.Monday) fmt.Println(result) // Output: - // 2023-01-08 00:00:00 +0000 UTC + // 2023-01-02 00:00:00 +0000 UTC } ``` @@ -743,7 +744,7 @@ func main() { func EndOfWeek(t time.Time, endWith ...time.Weekday) time.Time ``` -Example:[Run](https://go.dev/play/p/i08qKXD9flf) +Example:[Run](https://go.dev/play/p/mGSA162YgX9) ```go package main @@ -756,12 +757,12 @@ import ( func main() { input := time.Date(2023, 1, 8, 18, 50, 10, 100, time.UTC) - result := datetime.EndOfWeek(input) + result := datetime.EndOfWeek(input, time.Sunday) fmt.Println(result) // Output: - // 2023-01-14 23:59:59.999999999 +0000 UTC + // 2023-01-08 23:59:59.999999999 +0000 UTC } ```