solarlunar

package
v0.0.0-...-05d8bda Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 8 Imported by: 0

README

solarlunar

Build Status

1.阳历和阴历相互转化(支持1900~2049年)
2.节假日计算

快速开始

下载和安装
go get -u github.com/nosixtools/solarlunar
创建 solarlunar.go 阳历和阴历转化
package main 


import (
	"github.com/nosixtools/solarlunar" 
	"fmt"
)


func main() {
	solarDate := "1990-05-06"
	fmt.Println(solarlunar.SolarToChineseLuanr(solarDate))
	fmt.Println(solarlunar.SolarToSimpleLuanr(solarDate))
	
	lunarDate := "1990-04-12"
	fmt.Println(solarlunar.LunarToSolar(lunarDate, false))
}

创建 festival.go 节假日计算
package main


import (
"fmt"
"github.com/nosixtools/solarlunar/festival"
)

func main() {
	festival := festival.NewFestival("./festival.json")
	fmt.Println(festival.GetFestivals("2017-08-28"))
	fmt.Println(festival.GetFestivals("2017-05-01"))
	fmt.Println(festival.GetFestivals("2017-04-05"))
	fmt.Println(festival.GetFestivals("2017-10-01"))
	fmt.Println(festival.GetFestivals("2018-02-15"))
	fmt.Println(festival.GetFestivals("2018-02-16"))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CHINESENUMBER = []string{"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}
View Source
var CHINESENUMBERSPECIAL = []string{"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"}
View Source
var DATELAYOUT = "2006-01-02"
View Source
var LUNAR = "lunar"
View Source
var LUNAR_INFO = []int{}/* 150 elements not displayed */
View Source
var MAX_YEAR = 2049
View Source
var MIN_YEAR = 1900
View Source
var MONTHNUMBER = map[string]int{"January": 1, "February": 2, "March": 3, "April": 4, "May": 5, "June": 6, "July": 7, "August": 8, "September": 9, "October": 10, "November": 11, "December": 12}
View Source
var MONTH_LUNAR_FESTIVAL = map[string][]string{}
View Source
var MONTH_SOLAR_FESTIVAL = map[string][]string{}
View Source
var PATTERN = "^(solar|lunar)\\((?:m(\\d+)):(ld|(?:d|(?:fw|lw|w(\\d+))n|(?:s\\d+))(\\d+))\\)$"
View Source
var RULE_PATTERN = "^(solar|lunar)\\((?:m(\\d+)):(ld|(?:d|(?:fw|lw|w(\\d+))n|(?:s\\d+))(\\d+))\\)=\\S+$"
View Source
var SOLAR = "solar"
View Source
var STARTDATESTR = "1900-01-30"

Functions

func LunarToSolar

func LunarToSolar(date string, leapMonthFlag bool) string

func SolarToChineseLuanr

func SolarToChineseLuanr(date string) string

func SolarToLuanr

func SolarToLuanr(date string) (string, bool)

func SolarToSimpleLuanr

func SolarToSimpleLuanr(date string) string

Types

type Festival

type Festival struct {
	// contains filtered or unexported fields
}

func NewFestival

func NewFestival(filename string) *Festival

func (*Festival) GetFestivals

func (f *Festival) GetFestivals(solarDay string) (festivals []string)

Jump to

Keyboard shortcuts

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