go-china-holiday

基于colly实现的中国节假日查询的Go语言工具

MIT License

Stars
4
Committers
1

示例

package main

import (
	"fmt"
	holiday "github.com/piupuer/go-china-holiday"
)

func main() {
	h := holiday.New(holiday.WithFilename("holiday-data.txt"))
	// 检查指定日期是否是法定节假日
	fmt.Printf("2019-01-01是否节假日: %v\n\n", h.Check("2019-01-01"))

	// 列举2016年和2019所有节假日
	holidays, workdays := h.List(2016, 2019)

	fmt.Printf("2016年和2019年:\n节假日%v\n调休日(需要上班)%v\n\n", holidays, workdays)

	// 查询指定时间范围节假日(注意:将来的节假日需等gov.cn发布)
	holidays, workdays = h.Range("2008-01-01", "2022-12-01")

	fmt.Printf("2008-01-01至2022-12-01:\n节假日%v\n调休日(需要上班)%v\n", holidays, workdays)
}

互动交流

与作者对话

加群一起学习一起进步

QQ群:943724601

MIT License

Copyright (c) 2021 piupuer