chronos

package module
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 8 Imported by: 0

README

chronos

import "github.com/godcong/chronos/v2"

Index

Constants

DefaultDateFormat ...

const (
    DefaultDateFormat = "2006/01/02 15:04:05"
    LunarDateFormat   = "2006/01/02"
)
const (
    // LeapMonthSmall returns lunar small month
    LeapMonthSmall = 1
    // LeapMonthBig returns lunar big month
    LeapMonthBig = 2
)

Variables

var (
    // ErrYearNotHaveLeapMonth returns an error
    ErrYearNotHaveLeapMonth = errors.New("[chronos] year not have leap month")
    // ErrWrongTianGanTypes returns an error
    ErrWrongTianGanTypes = errors.New("[chronos] wrong tiangan types")
    // ErrWrongDiZhiTypes returns an error
    ErrWrongDiZhiTypes = errors.New("[chronos] wrong dizhi types")
    // ErrWrongGanZhiTypes returns an error
    ErrWrongGanZhiTypes = errors.New("[chronos] wrong ganzhi types")
    // ErrWrongZodiacTypes returns an error
    ErrWrongZodiacTypes = errors.New("[chronos] wrong zodiac types")
    // ErrWrongConstellationTypes returns an error
    ErrWrongConstellationTypes = errors.New("[chronos] wrong constellation types")
    // ErrWrongSolarTermFormat returns an error
    ErrWrongSolarTermFormat = errors.New("[chronos] wrong solar term format")
    // ErrWrongSolarTermIndex returns an error
    ErrWrongSolarTermIndex = errors.New("[chronos] wrong solar term index")
)
var (
    // PillarHour is an alias name of ShiZhu
    PillarHour = ShiZhu
    // PillarDay is an alias name of RiZhu
    PillarDay = RiZhu
    // PillarMonty is an alias name of YueZhu
    PillarMonty = YueZhu
    // PillarYear is an alias name of NianZhu
    PillarYear = NianZhu
)

func ConstellationChinese

func ConstellationChinese(c Constellation) (string, error)

ConstellationChinese returns a constellation of the chinese @param Constellation @return string @return error

func ConstellationChineseV2

func ConstellationChineseV2(c Constellation) string

ConstellationChineseV2 returns a constellation of the chinese @param Constellation @return string

func DiZhiChinese

func DiZhiChinese(dizhi DiZhi) (string, error)

DiZhiChinese returns the chinese DiZhi string @param DiZhi @return string @return error

func DiZhiChineseV2

func DiZhiChineseV2(dizhi DiZhi) string

DiZhiChineseV2 returns the chinese DiZhi string @param DiZhi @return string

func GanZhiChinese

func GanZhiChinese(ganzhi GanZhi) (string, error)

GanZhiChinese returns the chinese GanZhi string @param GanZhi @return string @return error

func GanZhiChineseV2

func GanZhiChineseV2(ganzhi GanZhi) string

GanZhiChineseV2 returns the chinese GanZhi string @param GanZhi @return string

func LeapMonth

func LeapMonth(t time.Time) (int, error)

LeapMonth returns the leap month if leap month is exists in the year @param time.Time @return int @return error

func LeapMonthBS

func LeapMonthBS(t time.Time) (int, error)

LeapMonthBS returns the leap month of big month or small month @param time.Time @return int @return error

func NianZhuChineseV2

func NianZhuChineseV2(t time.Time) string

NianZhuChineseV2 returns the chinese NianZhu string @param time.Time @return string

func SolarTermChinese

func SolarTermChinese(st SolarTerm) (string, error)

func SolarTermChineseV2

func SolarTermChineseV2(st SolarTerm) string

func TianGanChinese

func TianGanChinese(tiangan TianGan) (string, error)

TianGanChinese returns the chinese TianGan string @param TianGan @return string @return error

func TianGanChineseV2

func TianGanChineseV2(tiangan TianGan) string

TianGanChineseV2 returns the chinese TianGan string @param TianGan @return string

func YearGanZhiChinese

func YearGanZhiChinese(t time.Time) (string, error)

YearGanZhiChinese returns the year of the chinese GanZhi string @param int @return string @return error

func YearSolarTermDate

func YearSolarTermDate(t time.Time, st SolarTerm) (month time.Month, day int)

YearSolarTermDate returns the year month day of the solar term @param time.Time @param SolarTerm @return month @return day

func YearSolarTermDay

func YearSolarTermDay(t time.Time, st SolarTerm) (day int)

YearSolarTermDay returns the year day of the solar term @param time.Time @param SolarTerm @return day

func YearSolarTermMonth

func YearSolarTermMonth(t time.Time, st SolarTerm) (month time.Month)

YearSolarTermMonth returns the year month of the solar term @param time.Time @param SolarTerm @return month

func YueZhuChineseV2

func YueZhuChineseV2(t time.Time) string

YueZhuChineseV2 returns the chinese YueZhuChineseV2 string @param time.Time @return string

func ZodiacChinese

func ZodiacChinese(zodiac Zodiac) (string, error)

ZodiacChinese returns the chinese Zodiac string @param Zodiac @return string @return error

func ZodiacChineseV2

func ZodiacChineseV2(zodiac Zodiac) string

ZodiacChineseV2 returns the chinese Zodiac string @param Zodiac @return string

type Calendar

Calendar returns a calendar

type Calendar interface {
    Lunar() Lunar
    Solar() Solar
    FormatTime() string
    Time() time.Time
    Date() CalendarDate
}
func NewSolarCalendar
func NewSolarCalendar(v ...any) Calendar

NewSolarCalendar can input three type of time to create the calendar "2006/01/02 03:04" format string time.Time value or nil to create a new time.Now() value

func ParseSolarDate
func ParseSolarDate(year, month, day, hour, minute, second int) Calendar

ParseSolarDate returns Calendar parse from date(year, month, day, hour, minute, second) @param int @param int @param int @param int @param int @param int @return Calendar

func ParseSolarNow
func ParseSolarNow() Calendar

ParseSolarNow returns Calendar parse from solar time now(time.Now()) @return Calendar

func ParseSolarString
func ParseSolarString(s string, format ...string) Calendar

ParseSolarString returns Calendar parse from string(value,format?) @param string @param ...string @return Calendar

func ParseSolarTime
func ParseSolarTime(t time.Time) Calendar

ParseSolarTime returns Calendar parse from solar time @param time.Time @return Calendar

func ParseTime
func ParseTime(t time.Time, local *time.Location) Calendar

ParseTime parse time.Time to Calendar @param time.Time @param *time.Location @return Calendar

type CalendarDate

type CalendarDate struct {
    IsToday        bool           `json:"is_today"`
    Solar          SolarDate      `json:"solar"`
    Lunar          LunarDate      `json:"lunar"`
    EightCharacter EightCharacter `json:"eight_character"`
    Zodiac         Zodiac         `json:"zodiac"`
    Constellation  Constellation  `json:"constellation"`
    IsSolarTermDay bool           `json:"is_solar_day"`
    SolarTerm      SolarTerm      `json:"solar_term"`
}

type ChineseSupport

ChineseSupport implements the interface, if support chinese language output

type ChineseSupport interface {
    Chinese() string
}

type Constellation

Constellation ENUM(Capricorn,Aquarius,Pisces,Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scorpio,Sagittarius,Max)

type Constellation int
const (
    // ConstellationCapricorn is a Constellation of type Capricorn.
    ConstellationCapricorn Constellation = iota
    // ConstellationAquarius is a Constellation of type Aquarius.
    ConstellationAquarius
    // ConstellationPisces is a Constellation of type Pisces.
    ConstellationPisces
    // ConstellationAries is a Constellation of type Aries.
    ConstellationAries
    // ConstellationTaurus is a Constellation of type Taurus.
    ConstellationTaurus
    // ConstellationGemini is a Constellation of type Gemini.
    ConstellationGemini
    // ConstellationCancer is a Constellation of type Cancer.
    ConstellationCancer
    // ConstellationLeo is a Constellation of type Leo.
    ConstellationLeo
    // ConstellationVirgo is a Constellation of type Virgo.
    ConstellationVirgo
    // ConstellationLibra is a Constellation of type Libra.
    ConstellationLibra
    // ConstellationScorpio is a Constellation of type Scorpio.
    ConstellationScorpio
    // ConstellationSagittarius is a Constellation of type Sagittarius.
    ConstellationSagittarius
    // ConstellationMax is a Constellation of type Max.
    ConstellationMax
)
func GetConstellation
func GetConstellation(t time.Time) Constellation

GetConstellation get the constellation of date @param time.Time @return Constellation

func ParseConstellation
func ParseConstellation(name string) (Constellation, error)

ParseConstellation attempts to convert a string to a Constellation.

func (Constellation) Chinese
func (x Constellation) Chinese() string
func (Constellation) MarshalText
func (x Constellation) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Constellation) String
func (x Constellation) String() string

String implements the Stringer interface.

func (*Constellation) UnmarshalText
func (x *Constellation) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type DiZhi

DiZhi ENUM(Zi , Chou , Yin , Mao , Chen , Si , Wu , Wei , Shen , You , Xu , Hai , Max)

type DiZhi uint32
const (
    // DiZhiZi is a DiZhi of type Zi.
    DiZhiZi DiZhi = iota
    // DiZhiChou is a DiZhi of type Chou.
    DiZhiChou
    // DiZhiYin is a DiZhi of type Yin.
    DiZhiYin
    // DiZhiMao is a DiZhi of type Mao.
    DiZhiMao
    // DiZhiChen is a DiZhi of type Chen.
    DiZhiChen
    // DiZhiSi is a DiZhi of type Si.
    DiZhiSi
    // DiZhiWu is a DiZhi of type Wu.
    DiZhiWu
    // DiZhiWei is a DiZhi of type Wei.
    DiZhiWei
    // DiZhiShen is a DiZhi of type Shen.
    DiZhiShen
    // DiZhiYou is a DiZhi of type You.
    DiZhiYou
    // DiZhiXu is a DiZhi of type Xu.
    DiZhiXu
    // DiZhiHai is a DiZhi of type Hai.
    DiZhiHai
    // DiZhiMax is a DiZhi of type Max.
    DiZhiMax
)
func ParseDiZhi
func ParseDiZhi(name string) (DiZhi, error)

ParseDiZhi attempts to convert a string to a DiZhi.

func (DiZhi) Chinese
func (x DiZhi) Chinese() string
func (DiZhi) MarshalText
func (x DiZhi) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (DiZhi) String
func (x DiZhi) String() string

String implements the Stringer interface.

func (*DiZhi) UnmarshalText
func (x *DiZhi) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type EightCharacter

type EightCharacter struct {
    NianZhu GanZhi `json:"nian_zhu"`
    YueZhu  GanZhi `json:"yue_zhu"`
    Rizhu   GanZhi `json:"ri_zhu"`
    ShiZhu  GanZhi `json:"shi_zhu"`
}

type GanZhi

GanZhi returns the GanZhi enum ENUM(JiaZi,YiChou,BingYin,DingMao,WuChen,JiSi,GengWu,XinWei,RenShen,GuiYou,JiaXu,YiHai, BingZi,DingChou,WuYin,JiMao,GengChen,XinSi,RenWu,GuiWei,JiaShen,YiYou,BingXu,DingHai, WuZi,JiChou,GengYin,XinMao,RenChen,GuiSi,JiaWu,YiWei,BingShen,DingYou,WuXu,JiHai, GengZi,XinChou,RenYin,GuiMao,JiaChen,YiSi,BingWu,DingWei,WuShen,JiYou,GengXu,XinHai, RenZi,GuiChou,JiaYin,YiMao,BingChen,DingSi,WuWu,JiWei,GengShen,XinYou,RenXu,GuiHai,Max)

type GanZhi uint32
const (
    // GanZhiJiaZi is a GanZhi of type JiaZi.
    GanZhiJiaZi GanZhi = iota
    // GanZhiYiChou is a GanZhi of type YiChou.
    GanZhiYiChou
    // GanZhiBingYin is a GanZhi of type BingYin.
    GanZhiBingYin
    // GanZhiDingMao is a GanZhi of type DingMao.
    GanZhiDingMao
    // GanZhiWuChen is a GanZhi of type WuChen.
    GanZhiWuChen
    // GanZhiJiSi is a GanZhi of type JiSi.
    GanZhiJiSi
    // GanZhiGengWu is a GanZhi of type GengWu.
    GanZhiGengWu
    // GanZhiXinWei is a GanZhi of type XinWei.
    GanZhiXinWei
    // GanZhiRenShen is a GanZhi of type RenShen.
    GanZhiRenShen
    // GanZhiGuiYou is a GanZhi of type GuiYou.
    GanZhiGuiYou
    // GanZhiJiaXu is a GanZhi of type JiaXu.
    GanZhiJiaXu
    // GanZhiYiHai is a GanZhi of type YiHai.
    GanZhiYiHai
    // GanZhiBingZi is a GanZhi of type BingZi.
    GanZhiBingZi
    // GanZhiDingChou is a GanZhi of type DingChou.
    GanZhiDingChou
    // GanZhiWuYin is a GanZhi of type WuYin.
    GanZhiWuYin
    // GanZhiJiMao is a GanZhi of type JiMao.
    GanZhiJiMao
    // GanZhiGengChen is a GanZhi of type GengChen.
    GanZhiGengChen
    // GanZhiXinSi is a GanZhi of type XinSi.
    GanZhiXinSi
    // GanZhiRenWu is a GanZhi of type RenWu.
    GanZhiRenWu
    // GanZhiGuiWei is a GanZhi of type GuiWei.
    GanZhiGuiWei
    // GanZhiJiaShen is a GanZhi of type JiaShen.
    GanZhiJiaShen
    // GanZhiYiYou is a GanZhi of type YiYou.
    GanZhiYiYou
    // GanZhiBingXu is a GanZhi of type BingXu.
    GanZhiBingXu
    // GanZhiDingHai is a GanZhi of type DingHai.
    GanZhiDingHai
    // GanZhiWuZi is a GanZhi of type WuZi.
    GanZhiWuZi
    // GanZhiJiChou is a GanZhi of type JiChou.
    GanZhiJiChou
    // GanZhiGengYin is a GanZhi of type GengYin.
    GanZhiGengYin
    // GanZhiXinMao is a GanZhi of type XinMao.
    GanZhiXinMao
    // GanZhiRenChen is a GanZhi of type RenChen.
    GanZhiRenChen
    // GanZhiGuiSi is a GanZhi of type GuiSi.
    GanZhiGuiSi
    // GanZhiJiaWu is a GanZhi of type JiaWu.
    GanZhiJiaWu
    // GanZhiYiWei is a GanZhi of type YiWei.
    GanZhiYiWei
    // GanZhiBingShen is a GanZhi of type BingShen.
    GanZhiBingShen
    // GanZhiDingYou is a GanZhi of type DingYou.
    GanZhiDingYou
    // GanZhiWuXu is a GanZhi of type WuXu.
    GanZhiWuXu
    // GanZhiJiHai is a GanZhi of type JiHai.
    GanZhiJiHai
    // GanZhiGengZi is a GanZhi of type GengZi.
    GanZhiGengZi
    // GanZhiXinChou is a GanZhi of type XinChou.
    GanZhiXinChou
    // GanZhiRenYin is a GanZhi of type RenYin.
    GanZhiRenYin
    // GanZhiGuiMao is a GanZhi of type GuiMao.
    GanZhiGuiMao
    // GanZhiJiaChen is a GanZhi of type JiaChen.
    GanZhiJiaChen
    // GanZhiYiSi is a GanZhi of type YiSi.
    GanZhiYiSi
    // GanZhiBingWu is a GanZhi of type BingWu.
    GanZhiBingWu
    // GanZhiDingWei is a GanZhi of type DingWei.
    GanZhiDingWei
    // GanZhiWuShen is a GanZhi of type WuShen.
    GanZhiWuShen
    // GanZhiJiYou is a GanZhi of type JiYou.
    GanZhiJiYou
    // GanZhiGengXu is a GanZhi of type GengXu.
    GanZhiGengXu
    // GanZhiXinHai is a GanZhi of type XinHai.
    GanZhiXinHai
    // GanZhiRenZi is a GanZhi of type RenZi.
    GanZhiRenZi
    // GanZhiGuiChou is a GanZhi of type GuiChou.
    GanZhiGuiChou
    // GanZhiJiaYin is a GanZhi of type JiaYin.
    GanZhiJiaYin
    // GanZhiYiMao is a GanZhi of type YiMao.
    GanZhiYiMao
    // GanZhiBingChen is a GanZhi of type BingChen.
    GanZhiBingChen
    // GanZhiDingSi is a GanZhi of type DingSi.
    GanZhiDingSi
    // GanZhiWuWu is a GanZhi of type WuWu.
    GanZhiWuWu
    // GanZhiJiWei is a GanZhi of type JiWei.
    GanZhiJiWei
    // GanZhiGengShen is a GanZhi of type GengShen.
    GanZhiGengShen
    // GanZhiXinYou is a GanZhi of type XinYou.
    GanZhiXinYou
    // GanZhiRenXu is a GanZhi of type RenXu.
    GanZhiRenXu
    // GanZhiGuiHai is a GanZhi of type GuiHai.
    GanZhiGuiHai
    // GanZhiMax is a GanZhi of type Max.
    GanZhiMax
)
func NianZhu
func NianZhu(t time.Time) GanZhi

NianZhu returns a GanZhi of year @param time.Time @return string

func ParseGanZhi
func ParseGanZhi(name string) (GanZhi, error)

ParseGanZhi attempts to convert a string to a GanZhi.

func RiZhu
func RiZhu(t time.Time) GanZhi

RiZhu returns a GanZhi of day @param time.Time @return GanZhi

func ShiZhu
func ShiZhu(t time.Time) GanZhi

ShiZhu returns a GanZhi of hour @param time.Time @return GanZhi @descriptions 子   丑   寅   卯   辰   己 23-01:01-03:03-05 :05-07:07-09:09-11 午   未   申   酉   戊   亥 11-13:13-15:15-17:17-19:19-21:21-23 `甲子`, `乙丑`, `丙寅`, `丁卯`, `戊辰`, `己巳`, `庚午`, `辛未`, `壬申`, `癸酉`, `甲戌`, `乙亥`, //甲或己日 `丙子`, `丁丑`, `戊寅`, `己卯`, `庚辰`, `辛巳`, `壬午`, `癸未`, `甲申`, `乙酉`, `丙戌`, `丁亥`, //乙或庚日 `戊子`, `己丑`, `庚寅`, `辛卯`, `壬辰`, `癸巳`, `甲午`, `乙未`, `丙申`, `丁酉`, `戊戌`, `己亥`, //丙或辛日 `庚子`, `辛丑`, `壬寅`, `癸卯`, `甲辰`, `乙巳`, `丙午`, `丁未`, `戊申`, `己酉`, `庚戌`, `辛亥`, //丁或壬日 `壬子`, `癸丑`, `甲寅`, `乙卯`, `丙辰`, `丁巳`, `戊午`, `己未`, `庚申`, `辛酉`, `壬戌`, `癸亥`, //戊或癸日

func YueZhu
func YueZhu(t time.Time) GanZhi

YueZhu returns a GanZhi of month @param time.Time @return GanZhi

func (GanZhi) Chinese
func (x GanZhi) Chinese() string
func (GanZhi) MarshalText
func (x GanZhi) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (GanZhi) String
func (x GanZhi) String() string

String implements the Stringer interface.

func (*GanZhi) UnmarshalText
func (x *GanZhi) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Lunar

Lunar returns the lunar time

type Lunar interface {
    Year() int
    Month() int
    Day() int
    Hour() int
    LeapMonth() int
    IsLeapMonth() bool
}

type LunarDate

type LunarDate struct {
    Year        int  `json:"year"`
    Month       int  `json:"month"`
    Day         int  `json:"day"`
    Hour        int  `json:"hour"`
    IsLeapMonth bool `json:"is_leap_month"`
    LeapMonth   int  `json:"leap_month"`
}

type Solar

Solar returns the solar time

type Solar interface {
    Minute() int
    Second() int
    YearDay() int
    IsLeapYear() bool
    Year() int
    Month() time.Month
    Day() int
    Hour() int
}

type SolarDate

type SolarDate struct {
    Year    int          `json:"year"`
    Month   time.Month   `json:"month"`
    Day     int          `json:"day"`
    Hour    int          `json:"hour"`
    Minute  int          `json:"minute"`
    Second  int          `json:"second"`
    WeekDay time.Weekday `json:"week_day"`
}

type SolarTerm

SolarTerm ENUM(XiaoHan,DaHan,LiChun,YuShui,JingZhe,ChunFen,QingMing,GuYu,LiXia,XiaoMan,MangZhong,XiaZhi,XiaoShu,DaShu,LiQiu,ChuShu,BaiLu,QiuFen,HanLu,ShuangJiang,LiDong,XiaoXue,DaXue,DongZhi,Max)

type SolarTerm uint32
const (
    // SolarTermXiaoHan is a SolarTerm of type XiaoHan.
    SolarTermXiaoHan SolarTerm = iota
    // SolarTermDaHan is a SolarTerm of type DaHan.
    SolarTermDaHan
    // SolarTermLiChun is a SolarTerm of type LiChun.
    SolarTermLiChun
    // SolarTermYuShui is a SolarTerm of type YuShui.
    SolarTermYuShui
    // SolarTermJingZhe is a SolarTerm of type JingZhe.
    SolarTermJingZhe
    // SolarTermChunFen is a SolarTerm of type ChunFen.
    SolarTermChunFen
    // SolarTermQingMing is a SolarTerm of type QingMing.
    SolarTermQingMing
    // SolarTermGuYu is a SolarTerm of type GuYu.
    SolarTermGuYu
    // SolarTermLiXia is a SolarTerm of type LiXia.
    SolarTermLiXia
    // SolarTermXiaoMan is a SolarTerm of type XiaoMan.
    SolarTermXiaoMan
    // SolarTermMangZhong is a SolarTerm of type MangZhong.
    SolarTermMangZhong
    // SolarTermXiaZhi is a SolarTerm of type XiaZhi.
    SolarTermXiaZhi
    // SolarTermXiaoShu is a SolarTerm of type XiaoShu.
    SolarTermXiaoShu
    // SolarTermDaShu is a SolarTerm of type DaShu.
    SolarTermDaShu
    // SolarTermLiQiu is a SolarTerm of type LiQiu.
    SolarTermLiQiu
    // SolarTermChuShu is a SolarTerm of type ChuShu.
    SolarTermChuShu
    // SolarTermBaiLu is a SolarTerm of type BaiLu.
    SolarTermBaiLu
    // SolarTermQiuFen is a SolarTerm of type QiuFen.
    SolarTermQiuFen
    // SolarTermHanLu is a SolarTerm of type HanLu.
    SolarTermHanLu
    // SolarTermShuangJiang is a SolarTerm of type ShuangJiang.
    SolarTermShuangJiang
    // SolarTermLiDong is a SolarTerm of type LiDong.
    SolarTermLiDong
    // SolarTermXiaoXue is a SolarTerm of type XiaoXue.
    SolarTermXiaoXue
    // SolarTermDaXue is a SolarTerm of type DaXue.
    SolarTermDaXue
    // SolarTermDongZhi is a SolarTerm of type DongZhi.
    SolarTermDongZhi
    // SolarTermMax is a SolarTerm of type Max.
    SolarTermMax
)
func CheckSolarTermDay
func CheckSolarTermDay(t time.Time) (SolarTerm, bool)
func ParseSolarTerm
func ParseSolarTerm(name string) (SolarTerm, error)

ParseSolarTerm attempts to convert a string to a SolarTerm.

func (SolarTerm) Chinese
func (x SolarTerm) Chinese() string
func (SolarTerm) GetYearDate
func (x SolarTerm) GetYearDate(year int) (month time.Month, day int)
func (SolarTerm) String
func (x SolarTerm) String() string

String implements the Stringer interface.

type SolarTermDetail

SolarTermDetail 24节气表

type SolarTermDetail struct {
    Index       int       `json:"index"`
    SolarTerm   SolarTerm `json:"solar_term"`
    Time        string    `json:"time"`
    SanHou      string    `json:"san_hou"`
    Explanation string    `json:"explanation"`
}
func YearSolarTermDetail
func YearSolarTermDetail(t time.Time, st SolarTerm) (SolarTermDetail, error)

YearSolarTermDetail get the details of year solar term @param time.Time @param SolarTerm @return SolarTermDetail @return error

type StemBranch

StemBranch is an alias name for GanZhi

type StemBranch = GanZhi

type TianGan

TianGan ENUM(Jia , Yi , Bing , Ding , Wu , Ji , Geng , Xin , Ren , Gui , Max)

type TianGan uint32
const (
    // TianGanJia is a TianGan of type Jia.
    TianGanJia TianGan = iota
    // TianGanYi is a TianGan of type Yi.
    TianGanYi
    // TianGanBing is a TianGan of type Bing.
    TianGanBing
    // TianGanDing is a TianGan of type Ding.
    TianGanDing
    // TianGanWu is a TianGan of type Wu.
    TianGanWu
    // TianGanJi is a TianGan of type Ji.
    TianGanJi
    // TianGanGeng is a TianGan of type Geng.
    TianGanGeng
    // TianGanXin is a TianGan of type Xin.
    TianGanXin
    // TianGanRen is a TianGan of type Ren.
    TianGanRen
    // TianGanGui is a TianGan of type Gui.
    TianGanGui
    // TianGanMax is a TianGan of type Max.
    TianGanMax
)
func ParseTianGan
func ParseTianGan(name string) (TianGan, error)

ParseTianGan attempts to convert a string to a TianGan.

func (TianGan) Chinese
func (x TianGan) Chinese() string
func (TianGan) MarshalText
func (x TianGan) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (TianGan) String
func (x TianGan) String() string

String implements the Stringer interface.

func (*TianGan) UnmarshalText
func (x *TianGan) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Zodiac

Zodiac ENUM(Rat, Cow, Tiger, Rabbit, Dragon, Snake, Horse, Sheep, Monkey, Chicken, Dog, Pig, Max)

type Zodiac uint32
const (
    // ZodiacRat is a Zodiac of type Rat.
    ZodiacRat Zodiac = iota
    // ZodiacCow is a Zodiac of type Cow.
    ZodiacCow
    // ZodiacTiger is a Zodiac of type Tiger.
    ZodiacTiger
    // ZodiacRabbit is a Zodiac of type Rabbit.
    ZodiacRabbit
    // ZodiacDragon is a Zodiac of type Dragon.
    ZodiacDragon
    // ZodiacSnake is a Zodiac of type Snake.
    ZodiacSnake
    // ZodiacHorse is a Zodiac of type Horse.
    ZodiacHorse
    // ZodiacSheep is a Zodiac of type Sheep.
    ZodiacSheep
    // ZodiacMonkey is a Zodiac of type Monkey.
    ZodiacMonkey
    // ZodiacChicken is a Zodiac of type Chicken.
    ZodiacChicken
    // ZodiacDog is a Zodiac of type Dog.
    ZodiacDog
    // ZodiacPig is a Zodiac of type Pig.
    ZodiacPig
    // ZodiacMax is a Zodiac of type Max.
    ZodiacMax
)
func ParseZodiac
func ParseZodiac(name string) (Zodiac, error)

ParseZodiac attempts to convert a string to a Zodiac.

func YearZodiac
func YearZodiac(t time.Time) (Zodiac, error)

YearZodiac returns the zodiac of year.(pa: this will auto fix zodiac with LiChun check stopped at seconds) @param time.Time @return Zodiac @return error

func YearZodiacDay
func YearZodiacDay(t time.Time) (Zodiac, error)

YearZodiacDay returns the zodiac of year.(pa: this will auto fix zodiac with LiChun check stopped at day) @param time.Time @return Zodiac @return error

func YearZodiacNoFix
func YearZodiacNoFix(year int) Zodiac

YearZodiacNoFix returns the zodiac of year.(ps: this is not support LiChun day fix) @param int @return Zodiac

func (Zodiac) Chinese
func (x Zodiac) Chinese() string
func (Zodiac) MarshalText
func (x Zodiac) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Zodiac) String
func (x Zodiac) String() string

String implements the Stringer interface.

func (*Zodiac) UnmarshalText
func (x *Zodiac) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

Generated by gomarkdoc

Documentation

Index

Constants

View Source
const (
	// DateFormatYMD ...
	DateFormatYMD = "2006/01/02"
	// DateFormatYMDHMS ...
	DateFormatYMDHMS = "2006/01/02 15:04:05"
)
View Source
const (
	// LeapMonthSmall returns lunar small month
	LeapMonthSmall = 1
	// LeapMonthBig returns lunar big month
	LeapMonthBig = 2
)
View Source
const J2000 = 2451545

Variables

View Source
var (
	// ErrYearNotHaveLeapMonth returns an error
	ErrYearNotHaveLeapMonth = errors.New("[chronos] year not have leap month")
	// ErrWrongTianGanTypes returns an error
	ErrWrongTianGanTypes = errors.New("[chronos] wrong tiangan types")
	// ErrWrongDiZhiTypes returns an error
	ErrWrongDiZhiTypes = errors.New("[chronos] wrong dizhi types")
	// ErrWrongGanZhiTypes returns an error
	ErrWrongGanZhiTypes = errors.New("[chronos] wrong ganzhi types")
	// ErrWrongZodiacTypes returns an error
	ErrWrongZodiacTypes = errors.New("[chronos] wrong zodiac types")
	// ErrWrongConstellationTypes returns an error
	ErrWrongConstellationTypes = errors.New("[chronos] wrong constellation types")
	// ErrWrongSolarTermFormat returns an error
	ErrWrongSolarTermFormat = errors.New("[chronos] wrong solar term format")
	// ErrWrongSolarTermIndex returns an error
	ErrWrongSolarTermIndex = errors.New("[chronos] wrong solar term index")
)
View Source
var (
	// PillarHour is an alias name of ShiZhu
	PillarHour = ShiZhu
	// PillarDay is an alias name of RiZhu
	PillarDay = RiZhu
	// PillarMonty is an alias name of YueZhu
	PillarMonty = YueZhu
	// PillarYear is an alias name of NianZhu
	PillarYear = NianZhu
)

Functions

func ConstellationChinese

func ConstellationChinese(c Constellation) (string, error)

ConstellationChinese returns a constellation of the chinese @param Constellation @return string @return error

func ConstellationChineseV2

func ConstellationChineseV2(c Constellation) string

ConstellationChineseV2 returns a constellation of the chinese @param Constellation @return string

func DiZhiChinese

func DiZhiChinese(dizhi DiZhi) (string, error)

DiZhiChinese returns the chinese DiZhi string @param DiZhi @return string @return error

func DiZhiChineseV2

func DiZhiChineseV2(dizhi DiZhi) string

DiZhiChineseV2 returns the chinese DiZhi string @param DiZhi @return string

func GanZhiChinese

func GanZhiChinese(ganzhi GanZhi) (string, error)

GanZhiChinese returns the chinese GanZhi string @param GanZhi @return string @return error

func GanZhiChineseV2

func GanZhiChineseV2(ganzhi GanZhi) string

GanZhiChineseV2 returns the chinese GanZhi string @param GanZhi @return string

func LeapMonth

func LeapMonth(t time.Time) (int, error)

LeapMonth returns the leap month if leap month is exists in the year @param time.Time @return int @return error

func LeapMonthBS

func LeapMonthBS(t time.Time) (int, error)

LeapMonthBS returns the leap month of big month or small month @param time.Time @return int @return error

func NianZhuChineseV2

func NianZhuChineseV2(t time.Time) string

NianZhuChineseV2 returns the chinese NianZhu string @param time.Time @return string

func SolarTermChinese

func SolarTermChinese(st SolarTerm) (string, error)

func SolarTermChineseV2

func SolarTermChineseV2(st SolarTerm) string

func TianGanChinese

func TianGanChinese(tiangan TianGan) (string, error)

TianGanChinese returns the chinese TianGan string @param TianGan @return string @return error

func TianGanChineseV2

func TianGanChineseV2(tiangan TianGan) string

TianGanChineseV2 returns the chinese TianGan string @param TianGan @return string

func TimeFromY

func TimeFromY(y int) time.Time

func TimeFromYm

func TimeFromYm(y int, m time.Month) time.Time

func TimeFromYmd

func TimeFromYmd(y int, m time.Month, d int) time.Time

func TimeFromYmdHms

func TimeFromYmdHms(Y int, M time.Month, D int, h, m, s int) time.Time

func YearGanZhiChinese

func YearGanZhiChinese(t time.Time) (string, error)

YearGanZhiChinese returns the year of the chinese GanZhi string @param int @return string @return error

func YearSolarTermDate

func YearSolarTermDate(t time.Time, st SolarTerm) (month time.Month, day int)

YearSolarTermDate returns the year month day of the solar term @param time.Time @param SolarTerm @return month @return day

func YearSolarTermDay

func YearSolarTermDay(t time.Time, st SolarTerm) (day int)

YearSolarTermDay returns the year day of the solar term @param time.Time @param SolarTerm @return day

func YearSolarTermMonth

func YearSolarTermMonth(t time.Time, st SolarTerm) (month time.Month)

YearSolarTermMonth returns the year month of the solar term @param time.Time @param SolarTerm @return month

func YueZhuChineseV2

func YueZhuChineseV2(t time.Time) string

YueZhuChineseV2 returns the chinese YueZhuChineseV2 string @param time.Time @return string

func ZodiacChinese

func ZodiacChinese(zodiac Zodiac) (string, error)

ZodiacChinese returns the chinese Zodiac string @param Zodiac @return string @return error

func ZodiacChineseV2

func ZodiacChineseV2(zodiac Zodiac) string

ZodiacChineseV2 returns the chinese Zodiac string @param Zodiac @return string

Types

type Calendar

type Calendar interface {
	Lunar() Lunar
	Solar() Solar
}

Calendar returns a calendarTime

func NewSolarCalendar

func NewSolarCalendar(v ...any) Calendar

NewSolarCalendar can input three type of time to create the calendarTime "2006/01/02 03:04" format string time.Time value or nil to create a new time.Now() value

func ParseSolarDate

func ParseSolarDate(year, month, day, hour, minute, second int) Calendar

ParseSolarDate returns Calendar parse from date(year, month, day, hour, minute, second) @param int @param int @param int @param int @param int @param int @return Calendar

func ParseSolarNow

func ParseSolarNow() Calendar

ParseSolarNow returns Calendar parse from solar time now(time.Now()) @return Calendar

func ParseSolarString

func ParseSolarString(s string, format ...string) Calendar

ParseSolarString returns Calendar parse from string(value,format?) @param string @param ...string @return Calendar

func ParseSolarTime

func ParseSolarTime(t time.Time) Calendar

ParseSolarTime returns Calendar parse from solar time @param time.Time @return Calendar

func ParseTime

func ParseTime(t time.Time) Calendar

ParseTime parse time.Time to Calendar @param time.Time @param *time.Location @return Calendar

type CalendarDate

type CalendarDate struct {
	IsToday        bool           `json:"is_today"`
	Solar          SolarDate      `json:"solar"`
	Lunar          LunarDate      `json:"lunar"`
	EightCharacter EightCharacter `json:"eight_character"`
	Zodiac         Zodiac         `json:"zodiac"`
	Constellation  Constellation  `json:"constellation"`
	IsSolarTermDay bool           `json:"is_solar_day"`
	SolarTerm      SolarTerm      `json:"solar_term"`
}

type ChineseSupport

type ChineseSupport interface {
	Chinese() string
}

ChineseSupport implements the interface, if support chinese language output

type Constellation

type Constellation int

Constellation ENUM(Capricorn,Aquarius,Pisces,Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scorpio,Sagittarius,Max)

const (
	// ConstellationCapricorn is a Constellation of type Capricorn.
	ConstellationCapricorn Constellation = iota
	// ConstellationAquarius is a Constellation of type Aquarius.
	ConstellationAquarius
	// ConstellationPisces is a Constellation of type Pisces.
	ConstellationPisces
	// ConstellationAries is a Constellation of type Aries.
	ConstellationAries
	// ConstellationTaurus is a Constellation of type Taurus.
	ConstellationTaurus
	// ConstellationGemini is a Constellation of type Gemini.
	ConstellationGemini
	// ConstellationCancer is a Constellation of type Cancer.
	ConstellationCancer
	// ConstellationLeo is a Constellation of type Leo.
	ConstellationLeo
	// ConstellationVirgo is a Constellation of type Virgo.
	ConstellationVirgo
	// ConstellationLibra is a Constellation of type Libra.
	ConstellationLibra
	// ConstellationScorpio is a Constellation of type Scorpio.
	ConstellationScorpio
	// ConstellationSagittarius is a Constellation of type Sagittarius.
	ConstellationSagittarius
	// ConstellationMax is a Constellation of type Max.
	ConstellationMax
)

func GetConstellation

func GetConstellation(t time.Time) Constellation

GetConstellation get the constellation of date @param time.Time @return Constellation

func ParseConstellation

func ParseConstellation(name string) (Constellation, error)

ParseConstellation attempts to convert a string to a Constellation.

func (Constellation) Chinese

func (x Constellation) Chinese() string

func (Constellation) MarshalText

func (x Constellation) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Constellation) String

func (x Constellation) String() string

String implements the Stringer interface.

func (*Constellation) UnmarshalText

func (x *Constellation) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type DiZhi

type DiZhi uint32

DiZhi ENUM(Zi , Chou , Yin , Mao , Chen , Si , Wu , Wei , Shen , You , Xu , Hai , Max)

const (
	// DiZhiZi is a DiZhi of type Zi.
	DiZhiZi DiZhi = iota
	// DiZhiChou is a DiZhi of type Chou.
	DiZhiChou
	// DiZhiYin is a DiZhi of type Yin.
	DiZhiYin
	// DiZhiMao is a DiZhi of type Mao.
	DiZhiMao
	// DiZhiChen is a DiZhi of type Chen.
	DiZhiChen
	// DiZhiSi is a DiZhi of type Si.
	DiZhiSi
	// DiZhiWu is a DiZhi of type Wu.
	DiZhiWu
	// DiZhiWei is a DiZhi of type Wei.
	DiZhiWei
	// DiZhiShen is a DiZhi of type Shen.
	DiZhiShen
	// DiZhiYou is a DiZhi of type You.
	DiZhiYou
	// DiZhiXu is a DiZhi of type Xu.
	DiZhiXu
	// DiZhiHai is a DiZhi of type Hai.
	DiZhiHai
	// DiZhiMax is a DiZhi of type Max.
	DiZhiMax
)

func ParseDiZhi

func ParseDiZhi(name string) (DiZhi, error)

ParseDiZhi attempts to convert a string to a DiZhi.

func (DiZhi) Chinese

func (x DiZhi) Chinese() string

func (DiZhi) MarshalText

func (x DiZhi) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (DiZhi) String

func (x DiZhi) String() string

String implements the Stringer interface.

func (*DiZhi) UnmarshalText

func (x *DiZhi) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type EightChar

type EightChar interface {
	String() string
	//GetSect() int
	//SetSect(sect int)
	//GetDayGanIndex() int
	//GetDayZhiIndex() int
	//GetYear() string
	//GetYearGan() string
	//GetYearZhi() string
	//GetYearHideGan() []string
	//GetYearWuXing() string
	//GetYearNaYin() string
	//GetYearShiShenGan() string
	//GetYearShiShenZhi() *list.List
	//GetYearDiShi() string
	//GetMonth() string
	//GetMonthGan() string
	//GetMonthZhi() string
	//GetMonthHideGan() []string
	//GetMonthWuXing() string
	//GetMonthNaYin() string
	//GetMonthShiShenGan() string
	//GetMonthShiShenZhi() *list.List
	//GetMonthDiShi() string
	//GetDay() string
	//GetDayGan() string
	//GetDayZhi() string
	//GetDayHideGan() []string
	//GetDayWuXing() string
	//GetDayNaYin() string
	//GetDayShiShenGan() string
	//GetDayShiShenZhi() *list.List
	//GetDayDiShi() string
	//GetTime() string
	//GetTimeGan() string
	//GetTimeZhi() string
	//GetTimeHideGan() []string
	//GetTimeWuXing() string
	//GetTimeNaYin() string
	//GetTimeShiShenGan() string
	//GetTimeShiShenZhi() *list.List
	//GetTimeDiShi() string
	//GetTaiYuan() string
	//GetTaiYuanNaYin() string
	//GetTaiXi() string
	//GetTaiXiNaYin() string
	//GetMingGong() string
	//GetMingGongNaYin() string
	//GetShenGong() string
	//GetShenGongNaYin() string
	//GetLunar() *calendar.Lunar
	//GetYun(gender int) *calendar.Yun
	//GetYunBySect(gender int, sect int) *calendar.Yun
	//GetYearXun() string
	//GetYearXunKong() string
	//GetMonthXun() string
	//GetMonthXunKong() string
	//GetDayXun() string
	//GetDayXunKong() string
	//GetTimeXun() string
	//GetTimeXunKong() string
	GetWuXing() [4]string
	GetNaYin() [4]string
	GetSiZhu() [4]string
	GetShiShenGan() [4]string
	GetShiShenZhi() [4][]string
	GetCangGan() [4][]string
	GetDaYun(sex int) []int
}

EightChar returns the lunar eight char

type EightCharIndex

type EightCharIndex int
const (
	EightCharYear EightCharIndex = iota
	EightCharMonth
	EightCharDay
	EightCharTime
)

type EightCharacter

type EightCharacter struct {
	NianZhu GanZhi `json:"nian_zhu"`
	YueZhu  GanZhi `json:"yue_zhu"`
	Rizhu   GanZhi `json:"ri_zhu"`
	ShiZhu  GanZhi `json:"shi_zhu"`
}

type GanZhi

type GanZhi uint32

GanZhi returns the GanZhi enum ENUM(JiaZi,YiChou,BingYin,DingMao,WuChen,JiSi,GengWu,XinWei,RenShen,GuiYou,JiaXu,YiHai, BingZi,DingChou,WuYin,JiMao,GengChen,XinSi,RenWu,GuiWei,JiaShen,YiYou,BingXu,DingHai, WuZi,JiChou,GengYin,XinMao,RenChen,GuiSi,JiaWu,YiWei,BingShen,DingYou,WuXu,JiHai, GengZi,XinChou,RenYin,GuiMao,JiaChen,YiSi,BingWu,DingWei,WuShen,JiYou,GengXu,XinHai, RenZi,GuiChou,JiaYin,YiMao,BingChen,DingSi,WuWu,JiWei,GengShen,XinYou,RenXu,GuiHai,Max)

const (
	// GanZhiJiaZi is a GanZhi of type JiaZi.
	GanZhiJiaZi GanZhi = iota
	// GanZhiYiChou is a GanZhi of type YiChou.
	GanZhiYiChou
	// GanZhiBingYin is a GanZhi of type BingYin.
	GanZhiBingYin
	// GanZhiDingMao is a GanZhi of type DingMao.
	GanZhiDingMao
	// GanZhiWuChen is a GanZhi of type WuChen.
	GanZhiWuChen
	// GanZhiJiSi is a GanZhi of type JiSi.
	GanZhiJiSi
	// GanZhiGengWu is a GanZhi of type GengWu.
	GanZhiGengWu
	// GanZhiXinWei is a GanZhi of type XinWei.
	GanZhiXinWei
	// GanZhiRenShen is a GanZhi of type RenShen.
	GanZhiRenShen
	// GanZhiGuiYou is a GanZhi of type GuiYou.
	GanZhiGuiYou
	// GanZhiJiaXu is a GanZhi of type JiaXu.
	GanZhiJiaXu
	// GanZhiYiHai is a GanZhi of type YiHai.
	GanZhiYiHai
	// GanZhiBingZi is a GanZhi of type BingZi.
	GanZhiBingZi
	// GanZhiDingChou is a GanZhi of type DingChou.
	GanZhiDingChou
	// GanZhiWuYin is a GanZhi of type WuYin.
	GanZhiWuYin
	// GanZhiJiMao is a GanZhi of type JiMao.
	GanZhiJiMao
	// GanZhiGengChen is a GanZhi of type GengChen.
	GanZhiGengChen
	// GanZhiXinSi is a GanZhi of type XinSi.
	GanZhiXinSi
	// GanZhiRenWu is a GanZhi of type RenWu.
	GanZhiRenWu
	// GanZhiGuiWei is a GanZhi of type GuiWei.
	GanZhiGuiWei
	// GanZhiJiaShen is a GanZhi of type JiaShen.
	GanZhiJiaShen
	// GanZhiYiYou is a GanZhi of type YiYou.
	GanZhiYiYou
	// GanZhiBingXu is a GanZhi of type BingXu.
	GanZhiBingXu
	// GanZhiDingHai is a GanZhi of type DingHai.
	GanZhiDingHai
	// GanZhiWuZi is a GanZhi of type WuZi.
	GanZhiWuZi
	// GanZhiJiChou is a GanZhi of type JiChou.
	GanZhiJiChou
	// GanZhiGengYin is a GanZhi of type GengYin.
	GanZhiGengYin
	// GanZhiXinMao is a GanZhi of type XinMao.
	GanZhiXinMao
	// GanZhiRenChen is a GanZhi of type RenChen.
	GanZhiRenChen
	// GanZhiGuiSi is a GanZhi of type GuiSi.
	GanZhiGuiSi
	// GanZhiJiaWu is a GanZhi of type JiaWu.
	GanZhiJiaWu
	// GanZhiYiWei is a GanZhi of type YiWei.
	GanZhiYiWei
	// GanZhiBingShen is a GanZhi of type BingShen.
	GanZhiBingShen
	// GanZhiDingYou is a GanZhi of type DingYou.
	GanZhiDingYou
	// GanZhiWuXu is a GanZhi of type WuXu.
	GanZhiWuXu
	// GanZhiJiHai is a GanZhi of type JiHai.
	GanZhiJiHai
	// GanZhiGengZi is a GanZhi of type GengZi.
	GanZhiGengZi
	// GanZhiXinChou is a GanZhi of type XinChou.
	GanZhiXinChou
	// GanZhiRenYin is a GanZhi of type RenYin.
	GanZhiRenYin
	// GanZhiGuiMao is a GanZhi of type GuiMao.
	GanZhiGuiMao
	// GanZhiJiaChen is a GanZhi of type JiaChen.
	GanZhiJiaChen
	// GanZhiYiSi is a GanZhi of type YiSi.
	GanZhiYiSi
	// GanZhiBingWu is a GanZhi of type BingWu.
	GanZhiBingWu
	// GanZhiDingWei is a GanZhi of type DingWei.
	GanZhiDingWei
	// GanZhiWuShen is a GanZhi of type WuShen.
	GanZhiWuShen
	// GanZhiJiYou is a GanZhi of type JiYou.
	GanZhiJiYou
	// GanZhiGengXu is a GanZhi of type GengXu.
	GanZhiGengXu
	// GanZhiXinHai is a GanZhi of type XinHai.
	GanZhiXinHai
	// GanZhiRenZi is a GanZhi of type RenZi.
	GanZhiRenZi
	// GanZhiGuiChou is a GanZhi of type GuiChou.
	GanZhiGuiChou
	// GanZhiJiaYin is a GanZhi of type JiaYin.
	GanZhiJiaYin
	// GanZhiYiMao is a GanZhi of type YiMao.
	GanZhiYiMao
	// GanZhiBingChen is a GanZhi of type BingChen.
	GanZhiBingChen
	// GanZhiDingSi is a GanZhi of type DingSi.
	GanZhiDingSi
	// GanZhiWuWu is a GanZhi of type WuWu.
	GanZhiWuWu
	// GanZhiJiWei is a GanZhi of type JiWei.
	GanZhiJiWei
	// GanZhiGengShen is a GanZhi of type GengShen.
	GanZhiGengShen
	// GanZhiXinYou is a GanZhi of type XinYou.
	GanZhiXinYou
	// GanZhiRenXu is a GanZhi of type RenXu.
	GanZhiRenXu
	// GanZhiGuiHai is a GanZhi of type GuiHai.
	GanZhiGuiHai
	// GanZhiMax is a GanZhi of type Max.
	GanZhiMax
)

func NianZhu

func NianZhu(t time.Time) GanZhi

NianZhu returns a GanZhi of year @param time.Time @return string

func ParseGanZhi

func ParseGanZhi(name string) (GanZhi, error)

ParseGanZhi attempts to convert a string to a GanZhi.

func RiZhu

func RiZhu(t time.Time) GanZhi

RiZhu returns a GanZhi of day @param time.Time @return GanZhi

func ShiZhu

func ShiZhu(t time.Time) GanZhi

ShiZhu returns a GanZhi of hour @param time.Time @return GanZhi @descriptions 子   丑   寅   卯   辰   己 23-01:01-03:03-05 :05-07:07-09:09-11 午   未   申   酉   戊   亥 11-13:13-15:15-17:17-19:19-21:21-23 `甲子`, `乙丑`, `丙寅`, `丁卯`, `戊辰`, `己巳`, `庚午`, `辛未`, `壬申`, `癸酉`, `甲戌`, `乙亥`, //甲或己日 `丙子`, `丁丑`, `戊寅`, `己卯`, `庚辰`, `辛巳`, `壬午`, `癸未`, `甲申`, `乙酉`, `丙戌`, `丁亥`, //乙或庚日 `戊子`, `己丑`, `庚寅`, `辛卯`, `壬辰`, `癸巳`, `甲午`, `乙未`, `丙申`, `丁酉`, `戊戌`, `己亥`, //丙或辛日 `庚子`, `辛丑`, `壬寅`, `癸卯`, `甲辰`, `乙巳`, `丙午`, `丁未`, `戊申`, `己酉`, `庚戌`, `辛亥`, //丁或壬日 `壬子`, `癸丑`, `甲寅`, `乙卯`, `丙辰`, `丁巳`, `戊午`, `己未`, `庚申`, `辛酉`, `壬戌`, `癸亥`, //戊或癸日

func YueZhu

func YueZhu(t time.Time) GanZhi

YueZhu returns a GanZhi of month @param time.Time @return GanZhi

func (GanZhi) Chinese

func (x GanZhi) Chinese() string

func (GanZhi) MarshalText

func (x GanZhi) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (GanZhi) String

func (x GanZhi) String() string

String implements the Stringer interface.

func (*GanZhi) UnmarshalText

func (x *GanZhi) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Lunar

type Lunar interface {
	GetGan() string
	GetYearGan() string
	GetYearGanByLiChun() string
	GetYearGanExact() string
	GetZhi() string
	GetYearZhi() string
	GetYearZhiByLiChun() string
	GetYearZhiExact() string
	GetYearInGanZhi() string
	GetYearInGanZhiByLiChun() string
	GetYearInGanZhiExact() string
	GetMonthGan() string
	GetMonthGanExact() string
	GetMonthZhi() string
	GetMonthZhiExact() string
	GetMonthInGanZhi() string
	GetMonthInGanZhiExact() string
	GetDayGan() string
	GetDayGanExact() string
	GetDayGanExact2() string
	GetDayZhi() string
	GetDayZhiExact() string
	GetDayZhiExact2() string
	GetDayInGanZhi() string
	GetDayInGanZhiExact() string
	GetDayInGanZhiExact2() string
	GetTimeGan() string
	GetTimeZhi() string
	GetTimeInGanZhi() string
	GetZodiac() Zodiac
	GetYearInChinese() string
	GetMonthInChinese() string
	GetDayInChinese() string
	GetSeason() string
	GetJie() string
	GetQi() string
	GetWeek() int
	GetWeekInChinese() string
	GetXiu() string
	GetXiuLuck() string
	GetXiuSong() string
	GetZheng() string
	GetAnimal() string
	GetGong() string
	GetShou() string
	GetFestivals() *list.List
	GetOtherFestivals() *list.List
	GetPengZuGan() string
	GetPengZuZhi() string
	GetPositionXi() string
	GetPositionXiDesc() string
	GetPositionYangGui() string
	GetPositionYangGuiDesc() string
	GetPositionYinGui() string
	GetPositionYinGuiDesc() string
	GetPositionFu() string
	GetPositionFuDesc() string
	GetPositionCai() string
	GetPositionCaiDesc() string
	GetDayPositionXi() string
	GetDayPositionXiDesc() string
	GetDayPositionYangGui() string
	GetDayPositionYangGuiDesc() string
	GetDayPositionYinGui() string
	GetDayPositionYinGuiDesc() string
	GetDayPositionFu() string
	GetDayPositionFuBySect(sect int) string
	GetDayPositionFuDesc() string
	GetDayPositionFuDescBySect(sect int) string
	GetDayPositionCai() string
	GetDayPositionCaiDesc() string
	GetYearPositionTaiSui() string
	GetYearPositionTaiSuiBySect(sect int) string
	GetYearPositionTaiSuiDesc() string
	GetYearPositionTaiSuiDescBySect(sect int) string
	GetMonthPositionTaiSuiBySect(sect int) string
	GetMonthPositionTaiSui() string
	GetMonthPositionTaiSuiDesc() string
	GetMonthPositionTaiSuiDescBySect(sect int) string
	GetDayPositionTaiSuiBySect(sect int) string
	GetDayPositionTaiSui() string
	GetDayPositionTaiSuiDesc() string
	GetDayPositionTaiSuiDescBySect(sect int) string
	GetTimePositionXi() string
	GetTimePositionXiDesc() string
	GetTimePositionYangGui() string
	GetTimePositionYangGuiDesc() string
	GetTimePositionYinGui() string
	GetTimePositionYinGuiDesc() string
	GetTimePositionFu() string
	GetTimePositionFuDesc() string
	GetTimePositionCai() string
	GetTimePositionCaiDesc() string
	GetChong() string
	GetDayChong() string
	GetChongGan() string
	GetDayChongGan() string
	GetChongGanTie() string
	GetDayChongGanTie() string
	GetChongShengXiao() string
	GetDayChongShengXiao() string
	GetChongDesc() string
	GetDayChongDesc() string
	GetSha() string
	GetDaySha() string
	GetYearNaYin() string
	GetMonthNaYin() string
	GetDayNaYin() string
	GetTimeNaYin() string
	GetEightChar() EightChar
	GetZhiXing() string
	GetDayTianShen() string
	GetTimeTianShen() string
	GetDayTianShenType() string
	GetTimeTianShenType() string
	GetDayTianShenLuck() string
	GetTimeTianShenLuck() string
	GetDayPositionTai() string
	GetMonthPositionTai() string
	GetTimeChong() string
	GetTimeSha() string
	GetTimeChongGan() string
	GetTimeChongGanTie() string
	GetTimeChongShengXiao() string
	GetTimeChongDesc() string
	GetSolarTerm() SolarTerm
	GetSolarTermDetail() SolarTermDetail
	//GetJieQiTable() map[string]*calendar.Solar
	//GetJieQiList() *list.List
	GetDayYi() *list.List
	GetDayYiBySect(sect int) *list.List
	GetDayJi() *list.List
	GetDayJiBySect(sect int) *list.List
	GetDayJiShen() *list.List
	GetDayXiongSha() *list.List
	GetTimeYi() *list.List
	GetTimeJi() *list.List
	GetYueXiang() string
	GetYearNineStarBySect(sect int) *calendar.NineStar
	GetYearNineStar() *calendar.NineStar
	GetMonthNineStarBySect(sect int) *calendar.NineStar
	GetMonthNineStar() *calendar.NineStar
	GetDayNineStar() *calendar.NineStar
	GetTimeNineStar() *calendar.NineStar
	GetCurrentJieQi() *calendar.JieQi
	String() string
	ToFullString() string
	GetYear() int
	GetMonth() int
	GetDay() int
	GetHour() int
	GetMinute() int
	GetSecond() int
	GetTimeGanIndex() int
	GetTimeZhiIndex() int
	GetDayGanIndex() int
	GetDayGanIndexExact() int
	GetDayGanIndexExact2() int
	GetDayZhiIndex() int
	GetDayZhiIndexExact() int
	GetDayZhiIndexExact2() int
	GetMonthGanIndex() int
	GetMonthGanIndexExact() int
	GetMonthZhiIndex() int
	GetMonthZhiIndexExact() int
	GetYearGanIndex() int
	GetYearGanIndexByLiChun() int
	GetYearGanIndexExact() int
	GetYearZhiIndex() int
	GetYearZhiIndexByLiChun() int
	GetYearZhiIndexExact() int
	GetSolar() *calendar.Solar
	Next(days int) *calendar.Lunar
	GetYearXun() string
	GetYearXunByLiChun() string
	GetYearXunExact() string
	GetYearXunKong() string
	GetYearXunKongByLiChun() string
	GetYearXunKongExact() string
	GetMonthXun() string
	GetMonthXunExact() string
	GetMonthXunKong() string
	GetMonthXunKongExact() string
	GetDayXun() string
	GetDayXunExact() string
	GetDayXunExact2() string
	GetDayXunKong() string
	GetDayXunKongExact() string
	GetDayXunKongExact2() string
	GetTimeXun() string
	GetTimeXunKong() string
	GetShuJiu() *calendar.ShuJiu
	GetFu() *calendar.Fu
	GetLiuYao() string
	GetHou() string
	GetWuHou() string
	GetDayLu() string
	GetTime() *calendar.LunarTime
	GetTimes() []*calendar.LunarTime
	GetFoto() *calendar.Foto
	GetTao() *calendar.Tao
}

Lunar returns the lunar time

func ParseLunarTime

func ParseLunarTime(t time.Time) Lunar

type LunarDate

type LunarDate struct {
	Year        int  `json:"year"`
	Month       int  `json:"month"`
	Day         int  `json:"day"`
	Hour        int  `json:"hour"`
	IsLeapMonth bool `json:"is_leap_month"`
	LeapMonth   int  `json:"leap_month"`
}

type Solar

type Solar interface {
	IsLeapYear() bool
	GetWeek() int
	GetWeekInChinese() string
	GetConstellation() Constellation
	GetFestivals() *list.List
	GetOtherFestivals() *list.List
	GetYear() int
	GetMonth() int
	GetDay() int
	GetHour() int
	GetMinute() int
	GetSecond() int
	//GetCalendar() time.Time
	GetJulianDay() float64
	ToYmd() string
	ToYmdHms() string
	String() string
	ToFullString() string
	Next(days int, onlyWorkDays bool) *calendar.Solar
	GetLunar() *calendar.Lunar
}

Solar returns the solar time

func ParseSolarByTime

func ParseSolarByTime(date time.Time) Solar

type SolarDate

type SolarDate struct {
	Year    int          `json:"year"`
	Month   time.Month   `json:"month"`
	Day     int          `json:"day"`
	Hour    int          `json:"hour"`
	Minute  int          `json:"minute"`
	Second  int          `json:"second"`
	WeekDay time.Weekday `json:"week_day"`
}

type SolarTerm

type SolarTerm uint32

SolarTerm ENUM(XiaoHan,DaHan,LiChun,YuShui,JingZhe,ChunFen,QingMing,GuYu,LiXia,XiaoMan,MangZhong,XiaZhi,XiaoShu,DaShu,LiQiu,ChuShu,BaiLu,QiuFen,HanLu,ShuangJiang,LiDong,XiaoXue,DaXue,DongZhi,Max)

const (
	// SolarTermXiaoHan is a SolarTerm of type XiaoHan.
	SolarTermXiaoHan SolarTerm = iota
	// SolarTermDaHan is a SolarTerm of type DaHan.
	SolarTermDaHan
	// SolarTermLiChun is a SolarTerm of type LiChun.
	SolarTermLiChun
	// SolarTermYuShui is a SolarTerm of type YuShui.
	SolarTermYuShui
	// SolarTermJingZhe is a SolarTerm of type JingZhe.
	SolarTermJingZhe
	// SolarTermChunFen is a SolarTerm of type ChunFen.
	SolarTermChunFen
	// SolarTermQingMing is a SolarTerm of type QingMing.
	SolarTermQingMing
	// SolarTermGuYu is a SolarTerm of type GuYu.
	SolarTermGuYu
	// SolarTermLiXia is a SolarTerm of type LiXia.
	SolarTermLiXia
	// SolarTermXiaoMan is a SolarTerm of type XiaoMan.
	SolarTermXiaoMan
	// SolarTermMangZhong is a SolarTerm of type MangZhong.
	SolarTermMangZhong
	// SolarTermXiaZhi is a SolarTerm of type XiaZhi.
	SolarTermXiaZhi
	// SolarTermXiaoShu is a SolarTerm of type XiaoShu.
	SolarTermXiaoShu
	// SolarTermDaShu is a SolarTerm of type DaShu.
	SolarTermDaShu
	// SolarTermLiQiu is a SolarTerm of type LiQiu.
	SolarTermLiQiu
	// SolarTermChuShu is a SolarTerm of type ChuShu.
	SolarTermChuShu
	// SolarTermBaiLu is a SolarTerm of type BaiLu.
	SolarTermBaiLu
	// SolarTermQiuFen is a SolarTerm of type QiuFen.
	SolarTermQiuFen
	// SolarTermHanLu is a SolarTerm of type HanLu.
	SolarTermHanLu
	// SolarTermShuangJiang is a SolarTerm of type ShuangJiang.
	SolarTermShuangJiang
	// SolarTermLiDong is a SolarTerm of type LiDong.
	SolarTermLiDong
	// SolarTermXiaoXue is a SolarTerm of type XiaoXue.
	SolarTermXiaoXue
	// SolarTermDaXue is a SolarTerm of type DaXue.
	SolarTermDaXue
	// SolarTermDongZhi is a SolarTerm of type DongZhi.
	SolarTermDongZhi
	// SolarTermMax is a SolarTerm of type Max.
	SolarTermMax
)

func CheckSolarTermDay

func CheckSolarTermDay(t time.Time) (SolarTerm, bool)

func ParseSolarTerm

func ParseSolarTerm(name string) (SolarTerm, error)

ParseSolarTerm attempts to convert a string to a SolarTerm.

func (SolarTerm) Chinese

func (x SolarTerm) Chinese() string

func (SolarTerm) Explanation

func (x SolarTerm) Explanation() string

func (SolarTerm) GetYearDate

func (x SolarTerm) GetYearDate(year int) (month time.Month, day int)

func (SolarTerm) MarshalText

func (x SolarTerm) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (SolarTerm) SanHou

func (x SolarTerm) SanHou() string

func (SolarTerm) String

func (x SolarTerm) String() string

String implements the Stringer interface.

func (*SolarTerm) UnmarshalText

func (x *SolarTerm) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type SolarTermDetail

type SolarTermDetail struct {
	Index       int       `json:"index"`
	SolarTerm   SolarTerm `json:"solar_term"`
	Time        string    `json:"time"`
	SanHou      string    `json:"san_hou"`
	Explanation string    `json:"explanation"`
}

SolarTermDetail 24节气表

func YearSolarTermDetail

func YearSolarTermDetail(t time.Time, st SolarTerm) (SolarTermDetail, error)

YearSolarTermDetail get the details of year solar term @param time.Time @param SolarTerm @return SolarTermDetail @return error

type StemBranch

type StemBranch = GanZhi

StemBranch is an alias name for GanZhi

type TianGan

type TianGan uint32

TianGan ENUM(Jia , Yi , Bing , Ding , Wu , Ji , Geng , Xin , Ren , Gui , Max)

const (
	// TianGanJia is a TianGan of type Jia.
	TianGanJia TianGan = iota
	// TianGanYi is a TianGan of type Yi.
	TianGanYi
	// TianGanBing is a TianGan of type Bing.
	TianGanBing
	// TianGanDing is a TianGan of type Ding.
	TianGanDing
	// TianGanWu is a TianGan of type Wu.
	TianGanWu
	// TianGanJi is a TianGan of type Ji.
	TianGanJi
	// TianGanGeng is a TianGan of type Geng.
	TianGanGeng
	// TianGanXin is a TianGan of type Xin.
	TianGanXin
	// TianGanRen is a TianGan of type Ren.
	TianGanRen
	// TianGanGui is a TianGan of type Gui.
	TianGanGui
	// TianGanMax is a TianGan of type Max.
	TianGanMax
)

func ParseTianGan

func ParseTianGan(name string) (TianGan, error)

ParseTianGan attempts to convert a string to a TianGan.

func (TianGan) Chinese

func (x TianGan) Chinese() string

func (TianGan) MarshalText

func (x TianGan) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (TianGan) String

func (x TianGan) String() string

String implements the Stringer interface.

func (*TianGan) UnmarshalText

func (x *TianGan) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Zodiac

type Zodiac uint32

Zodiac ENUM(Rat, Cow, Tiger, Rabbit, Dragon, Snake, Horse, Sheep, Monkey, Chicken, Dog, Pig, Max)

const (
	// ZodiacRat is a Zodiac of type Rat.
	ZodiacRat Zodiac = iota
	// ZodiacCow is a Zodiac of type Cow.
	ZodiacCow
	// ZodiacTiger is a Zodiac of type Tiger.
	ZodiacTiger
	// ZodiacRabbit is a Zodiac of type Rabbit.
	ZodiacRabbit
	// ZodiacDragon is a Zodiac of type Dragon.
	ZodiacDragon
	// ZodiacSnake is a Zodiac of type Snake.
	ZodiacSnake
	// ZodiacHorse is a Zodiac of type Horse.
	ZodiacHorse
	// ZodiacSheep is a Zodiac of type Sheep.
	ZodiacSheep
	// ZodiacMonkey is a Zodiac of type Monkey.
	ZodiacMonkey
	// ZodiacChicken is a Zodiac of type Chicken.
	ZodiacChicken
	// ZodiacDog is a Zodiac of type Dog.
	ZodiacDog
	// ZodiacPig is a Zodiac of type Pig.
	ZodiacPig
	// ZodiacMax is a Zodiac of type Max.
	ZodiacMax
)

func ParseZodiac

func ParseZodiac(name string) (Zodiac, error)

ParseZodiac attempts to convert a string to a Zodiac.

func YearZodiac

func YearZodiac(t time.Time, lichun time.Time) Zodiac

YearZodiac returns the zodiac of year.(ps: this will auto fix zodiac with LiChun check stopped at seconds) @param time.Time @return Zodiac @return error

func YearZodiacDay

func YearZodiacDay(t time.Time, lichun time.Time) Zodiac

YearZodiacDay returns the zodiac of year.(ps: this will auto fix zodiac with LiChun check stopped at day) @param time.Time @return Zodiac @return error

func YearZodiacNoFix

func YearZodiacNoFix(year int) Zodiac

YearZodiacNoFix returns the zodiac of year.(ps: this is not support LiChun day fix) @param int @return Zodiac

func (Zodiac) Chinese

func (x Zodiac) Chinese() string

func (Zodiac) MarshalText

func (x Zodiac) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (Zodiac) String

func (x Zodiac) String() string

String implements the Stringer interface.

func (*Zodiac) UnmarshalText

func (x *Zodiac) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

Directories

Path Synopsis
tempdata

Jump to

Keyboard shortcuts

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