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

Function ExampleAddMonth

datetime/datetime_example_test.go:37–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35}
36
37func ExampleAddMonth() {
38 date, _ := time.Parse("2006-01-02", "2021-01-01")
39
40 after2Months := AddMonth(date, 2)
41 before2Months := AddMonth(date, -2)
42
43 fmt.Println(after2Months.Format("2006-01-02"))
44 fmt.Println(before2Months.Format("2006-01-02"))
45
46 // Output:
47 // 2021-03-01
48 // 2020-11-01
49}
50
51func ExampleAddHour() {
52 date, _ := time.Parse("2006-01-02 15:04:05", "2021-01-01 00:00:00")

Callers

nothing calls this directly

Calls 2

AddMonthFunction · 0.85
FormatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…