@@ -1046,6 +1046,90 @@ func ExampleWithStartAt() {
10461046 // 9999-09-09 09:09:09.000000009 +0000 UTC
10471047}
10481048
1049+ func ExampleWithStartDateTime () {
1050+ s , _ := gocron .NewScheduler ()
1051+ defer func () { _ = s .Shutdown () }()
1052+
1053+ start := time .Date (9999 , 9 , 9 , 9 , 9 , 9 , 9 , time .UTC )
1054+
1055+ j , _ := s .NewJob (
1056+ gocron .DurationJob (
1057+ time .Second ,
1058+ ),
1059+ gocron .NewTask (
1060+ func (one string , two int ) {
1061+ fmt .Printf ("%s, %d" , one , two )
1062+ },
1063+ "one" , 2 ,
1064+ ),
1065+ gocron .WithStartAt (
1066+ gocron .WithStartDateTime (start ),
1067+ ),
1068+ )
1069+ s .Start ()
1070+
1071+ next , _ := j .NextRun ()
1072+ fmt .Println (next )
1073+
1074+ _ = s .StopJobs ()
1075+ // Output:
1076+ // 9999-09-09 09:09:09.000000009 +0000 UTC
1077+ }
1078+
1079+ func ExampleWithStartDateTimePast () {
1080+ s , _ := gocron .NewScheduler ()
1081+ defer func () { _ = s .Shutdown () }()
1082+
1083+ start := time .Now ().Add (- time .Minute )
1084+
1085+ j , _ := s .NewJob (
1086+ gocron .DurationJob (
1087+ time .Second ,
1088+ ),
1089+ gocron .NewTask (
1090+ func (one string , two int ) {
1091+ fmt .Printf ("%s, %d" , one , two )
1092+ },
1093+ "one" , 2 ,
1094+ ),
1095+ gocron .WithStartAt (
1096+ gocron .WithStartDateTimePast (start ),
1097+ ),
1098+ )
1099+ s .Start ()
1100+
1101+ time .Sleep (100 * time .Millisecond )
1102+
1103+ _ , _ = j .NextRun ()
1104+
1105+ _ = s .StopJobs ()
1106+ }
1107+
1108+ func ExampleWithStartImmediately () {
1109+ s , _ := gocron .NewScheduler ()
1110+ defer func () { _ = s .Shutdown () }()
1111+
1112+ j , _ := s .NewJob (
1113+ gocron .DurationJob (
1114+ time .Second ,
1115+ ),
1116+ gocron .NewTask (
1117+ func (one string , two int ) {
1118+ fmt .Printf ("%s, %d" , one , two )
1119+ },
1120+ "one" , 2 ,
1121+ ),
1122+ gocron .WithStartAt (
1123+ gocron .WithStartImmediately (),
1124+ ),
1125+ )
1126+ s .Start ()
1127+
1128+ _ , _ = j .NextRun ()
1129+
1130+ _ = s .StopJobs ()
1131+ }
1132+
10491133func ExampleWithStopTimeout () {
10501134 _ , _ = gocron .NewScheduler (
10511135 gocron .WithStopTimeout (time .Second * 5 ),
0 commit comments