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

Function ExampleAddYear

datetime/datetime_example_test.go:79–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77}
78
79func ExampleAddYear() {
80 date, _ := time.Parse("2006-01-02", "2021-01-01")
81
82 after2Years := AddYear(date, 2)
83 before2Years := AddYear(date, -2)
84
85 fmt.Println(after2Years.Format("2006-01-02"))
86 fmt.Println(before2Years.Format("2006-01-02"))
87
88 // Output:
89 // 2023-01-01
90 // 2019-01-01
91}
92
93func ExampleAddDaySafe() {
94 leapYearDate1, _ := time.Parse("2006-01-02", "2024-02-29")

Callers

nothing calls this directly

Calls 2

AddYearFunction · 0.85
FormatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…