astro

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 8 Imported by: 0

README

astro

介绍

通过新历日期获取星座,农历以及生肖

安装教程

go get github.com/jageros/hawox

使用例子
package main

import (
	"fmt"
	"github.com/jageros/hawox/astro"
)

func main() {
	date := "1993-08-28"
	nDate := astro.Lunar(date)
	animal := astro.GetAnimal(date)
	constellation := astro.GetConstellation(date)

	fmt.Printf("新历:%s\n", date)
	fmt.Printf("农历:%s\n", nDate)
	fmt.Printf("生肖:%s\n", animal)
	fmt.Printf("星座:%s\n", constellation)
}
使用说明
  1. astro.Lunar("xxxx-xx-xx") 新历日期转农历
  2. astro.GetAnimal("xxxx-xx-xx") 新历日期获取生肖
  3. astro.GetConstellation("xxxx-xx-xx") 新历日期获取星座

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConstellation

func GetConstellation(date string) string

func InitFromJsonFile

func InitFromJsonFile(path string) error

func InitFromUrl

func InitFromUrl(url string) error

Types

type Date

type Date struct {
	Year         int      `json:"year"`
	Month        int      `json:"month"`
	Day          int      `json:"day"`
	LunarMonth   string   `json:"lunar_month"`
	LunarDay     string   `json:"lunar_day"`
	Week         int      `json:"week"`
	IsLargeMonth bool     `json:"is_large_month"`
	Animal       string   `json:"animal"`
	YearGanZhi   string   `json:"year_gan_zhi"`
	MonthGanZhi  string   `json:"month_gan_zhi"`
	DayGanZhi    string   `json:"day_gan_zhi"`
	Festivals    []string `json:"festivals"`
	Suitable     []string `json:"suitable"`
	Avoid        []string `json:"avoid"`
}

func GetDate

func GetDate(date string) *Date

GetDate 根据日期获取黄历数据,参数date格式: 2006-01-02

func (*Date) Constellation

func (d *Date) Constellation() string

func (*Date) Key

func (d *Date) Key() string

func (*Date) Map

func (d *Date) Map(hour int) (map[string]interface{}, error)

func (*Date) NewEightWord

func (d *Date) NewEightWord(hour int) *EightWord

func (*Date) String

func (d *Date) String() string

func (*Date) WeekString

func (d *Date) WeekString() string

type EightWord

type EightWord struct {
	*Date
	// contains filtered or unexported fields
}

func (*EightWord) EWString

func (ew *EightWord) EWString() string

func (*EightWord) HourGanZhi

func (ew *EightWord) HourGanZhi() string

func (*EightWord) MissWuXingAttr

func (ew *EightWord) MissWuXingAttr() []string

func (*EightWord) Word

func (ew *EightWord) Word() string

func (*EightWord) Words

func (ew *EightWord) Words() []string

func (*EightWord) WuXingAttr

func (ew *EightWord) WuXingAttr() []string

Jump to

Keyboard shortcuts

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