MCPcopy Index your code
hub / github.com/duke-git/lancet / ExampleAddYearSafe

Function ExampleAddYearSafe

datetime/datetime_example_test.go:133–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131}
132
133func ExampleAddYearSafe() {
134 date, _ := time.Parse("2006-01-02", "2020-02-29")
135
136 result1 := AddYearSafe(date, 1)
137 result2 := AddYearSafe(date, -1)
138
139 fmt.Println(result1.Format("2006-01-02"))
140 fmt.Println(result2.Format("2006-01-02"))
141
142 // Output:
143 // 2021-02-28
144 // 2019-02-28
145}
146
147func ExampleGetNowDate() {
148 result := GetNowDate()

Callers

nothing calls this directly

Calls 2

AddYearSafeFunction · 0.85
FormatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…