MCPcopy
hub / github.com/duke-git/lancet / ExampleAddMonthSafe

Function ExampleAddMonthSafe

datetime/datetime_example_test.go:118–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116}
117
118func ExampleAddMonthSafe() {
119 date1, _ := time.Parse("2006-01-02", "2025-01-31")
120 result1 := AddMonthSafe(date1, 1)
121
122 date2, _ := time.Parse("2006-01-02", "2024-02-29")
123 result2 := AddMonthSafe(date2, -1)
124
125 fmt.Println(result1.Format("2006-01-02"))
126 fmt.Println(result2.Format("2006-01-02"))
127
128 // Output:
129 // 2025-02-28
130 // 2024-01-29
131}
132
133func ExampleAddYearSafe() {
134 date, _ := time.Parse("2006-01-02", "2020-02-29")

Callers

nothing calls this directly

Calls 2

AddMonthSafeFunction · 0.85
FormatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…