lunar

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2016 License: MIT Imports: 14 Imported by: 0

README

农历-公历换算库(for golang)

使用查表法,数据来源香港天文台

文档

例子

Documentation

Index

Constants

View Source
const (
	//BEGIN 开始年份
	BEGIN = 1901
	//END 结束年份
	END = 2100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Crawler

type Crawler struct {
}

Crawler 爬虫 抓取香港天文台数据

func (*Crawler) Fetch

func (p *Crawler) Fetch() error

Fetch 获得日历数据

func (*Crawler) Store

func (p *Crawler) Store(q Query) error

Store store to database

type Date

type Date struct {
	ID uint `gorm:"primary_key"`

	SYear  int `gorm:"type:smallint;not null"`
	SMonth int `gorm:"type:smallint;not null"`
	SDay   int `gorm:"type:smallint;not null"`
	LYear  int `gorm:"type:smallint;not null"`
	LMonth int `gorm:"type:smallint;not null"`
	LDay   int `gorm:"type:smallint;not null"`

	Term string `gorm:"type:varchar(12);index"`
	//Term int  `gorm:"not null"`
	Leap bool `gorm:"not null"`
}

Date 中国农历-公历数据

func (Date) TableName

func (Date) TableName() string

TableName set Date's table name

type GormQuery

type GormQuery struct {
	Db *gorm.DB
}

GormQuery query by gorm

func (*GormQuery) Clear

func (p *GormQuery) Clear() error

Clear clear table items

func (*GormQuery) FromLunar

func (p *GormQuery) FromLunar(y, m, d int) ([]Date, error)

FromLunar 从农历查询

func (*GormQuery) FromSolar

func (p *GormQuery) FromSolar(y, m, d int) (Date, error)

FromSolar 从公历查询

func (*GormQuery) Prepare

func (p *GormQuery) Prepare() error

Prepare create table and indexes

func (*GormQuery) Write

func (p *GormQuery) Write(item *Date) error

Write create a new record

type PgSQLQuery

type PgSQLQuery struct {
	Db *sql.DB
}

PgSQLQuery query by gorm

func (*PgSQLQuery) Clear

func (p *PgSQLQuery) Clear() error

Clear clear table items

func (*PgSQLQuery) FromLunar

func (p *PgSQLQuery) FromLunar(y, m, d int) ([]Date, error)

FromLunar 从农历查询

func (*PgSQLQuery) FromSolar

func (p *PgSQLQuery) FromSolar(y, m, d int) (Date, error)

FromSolar 从公历查询

func (*PgSQLQuery) Prepare

func (p *PgSQLQuery) Prepare() error

Prepare create table and indexes

func (*PgSQLQuery) Write

func (p *PgSQLQuery) Write(item *Date) error

Write create a new record

type Query

type Query interface {
	Prepare() error
	Write(*Date) error
	Clear() error
	FromSolar(y, m, d int) (Date, error)
	FromLunar(y, m, d int) ([]Date, error)
}

Query query tools

Jump to

Keyboard shortcuts

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