()
| 77 | } |
| 78 | |
| 79 | func 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 | |
| 93 | func ExampleAddDaySafe() { |
| 94 | leapYearDate1, _ := time.Parse("2006-01-02", "2024-02-29") |