workingday

package module
v0.0.0-...-db88878 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 6 Imported by: 0

README

go-workingday

判断某天是不是工作日,目前支持🇨🇳大陆, 🇨🇳台湾, 🇨🇳澳门,🇨🇳香港

由于国务院放假安排每年可能都不一样,所以仅支持年以及三年前的数据,后续版本可能将支持手动添加放假数据

a golang package to get workday info, currently suport cn, tw, ma, hk region

as holiday arrangement is defferent every year, it's arranged accroading to related govement files, we only support current year and passed 3 years calculation, may add manual data in the later versions

使用示例(example):
package main

import (
	"github.com/Admingyu/go-workingday"
	"log"
	"time"
)

func main() {
	dt := time.Now()
	region := "CN"
	isWork, dayType := workingday.IsWorkDay(dt, region)

	log.Print("现在是:", dt)
	log.Print("地区:", region)
	log.Print("今天需要上班?", isWork)
	log.Print("原因:", dayType)
}

数据来源:http://www.suishenyun.net

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillCalendar

func FillCalendar() calendarBody

获取假日表并解析

func GetRegionHolidays

func GetRegionHolidays(region string) []dayType

获取某个地区假日数据 region: 地区(CN:中国大陆。 HK:中国香港, MA:中国澳门, TW:中国台湾)

func IsWorkDay

func IsWorkDay(dateIn time.Time, region string) (bool, string)

判断今天是不是工作日: dataIn 当前时间 region 地区(CN:中国大陆。 HK:中国香港, MA:中国澳门, TW:中国台湾) 返回参数:是否是工作日(true:上班, false:不上班),当前状态:(NORMAL:正常,WORK:调休上班,REST:假期)

func LastThirdWorkDay

func LastThirdWorkDay(datetime time.Time) time.Time

获取日期月份倒数第三个工作日

func NthWorkdayFromLast

func NthWorkdayFromLast(datetime time.Time, n int, region string) time.Time

获取指定日期所属月份的倒数第n个工作日

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL