2013-09-01 13:24:01 +00:00
|
|
|
/*!
|
|
|
|
* Copyright 2013 Raymond Hill
|
|
|
|
*
|
|
|
|
* Project: github.com/gorhill/example_test.go
|
|
|
|
* File: example_test.go
|
|
|
|
* Version: 1.0
|
|
|
|
* License: GPL v3 see <https://www.gnu.org/licenses/gpl.html>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-15 18:30:32 +00:00
|
|
|
package cronexpr
|
2013-09-01 13:24:01 +00:00
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2013-09-02 20:03:21 +00:00
|
|
|
// ExampleMustParse
|
|
|
|
func ExampleMustParse() {
|
2013-09-01 13:24:01 +00:00
|
|
|
t := time.Date(2013, time.August, 31, 0, 0, 0, 0, time.UTC)
|
2017-09-15 18:30:32 +00:00
|
|
|
nextTimes := MustParse("0 0 29 2 *").NextN(t, 5)
|
2013-09-01 13:24:01 +00:00
|
|
|
for i := range nextTimes {
|
|
|
|
fmt.Println(nextTimes[i].Format(time.RFC1123))
|
|
|
|
// Output:
|
|
|
|
// Mon, 29 Feb 2016 00:00:00 UTC
|
|
|
|
// Sat, 29 Feb 2020 00:00:00 UTC
|
|
|
|
// Thu, 29 Feb 2024 00:00:00 UTC
|
|
|
|
// Tue, 29 Feb 2028 00:00:00 UTC
|
|
|
|
// Sun, 29 Feb 2032 00:00:00 UTC
|
|
|
|
}
|
|
|
|
}
|