-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from winebarrel/fix_NestIF
Fix Next() retval
- Loading branch information
Showing
4 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/winebarrel/jhol" | ||
) | ||
|
||
func parseDate(s string) time.Time { | ||
d, _ := time.ParseInLocation("2006-01-02", s, time.Local) | ||
return d | ||
} | ||
|
||
func main() { | ||
apiKey := os.Getenv("GOOGLE_API_KEY") | ||
client := jhol.NewClient(apiKey).WithoutContext() | ||
|
||
date := parseDate("2023-07-17") | ||
h, _ := client.Get(date) | ||
fmt.Println(h) //=> 2023-07-17 海の日 | ||
|
||
yes, _ := client.IsHoliday(date) | ||
fmt.Println(yes) //=> true | ||
|
||
h, _ = client.Next(date) | ||
fmt.Println(h) //=> 2023-07-17 海の日 | ||
|
||
holidays, _ := client.NextN(date, 3) | ||
fmt.Println(holidays) //=> [2023-07-17 海の日 2023-08-11 山の日 2023-09-18 敬老の日] | ||
|
||
holidays, _ = client.Between(date, parseDate("2023-08-11")) | ||
fmt.Println(holidays) //=> [2023-07-17 海の日 2023-08-11 山の日] | ||
} |