Documentation ¶
Index ¶
- Constants
- Variables
- func AnimalYear(year int) string
- func DiffYMD(year, month, day, targetYear, targetMonth, targetDay int) int
- func Gan(x int) string
- func GanZhi(x int) string
- func GanZhiYMD(sYear, sMonth, sDay int) (gzYear, gzMonth, gzDay string)
- func IsLeapYear(year int) bool
- func IsLunarZero(l *Lunar) bool
- func JieQi(year, n int) int
- func JieQiDay(year, month int) (firstDayName string, firstDay int, secondDayName string, secondDay int)
- func JieQisOfMonth(year, m int) (first, second int)
- func JieQisOfYear(year int) (list [12][2]int)
- func LeapDays(year int) int
- func LeapMonth(year int) int
- func LunarDayString(day int) (s string)
- func LunarMonthDays(year, month int) int
- func LunarMonthString(month int, leap bool) string
- func LunarMonths(year int) int
- func LunarYearDays(year int) int
- func LunarYearString(year int) string
- func SolarMonthDays(year int, month int) int
- func SplitDuration(second, nanosecond int) (days, hours, minutes, seconds, nsecs int)
- func Zhi(x int) string
- func ZhiHour(hour int) (zHour string)
- type FestivalMap
- type Lunar
- func (l Lunar) Add(years, months, days, hours, mins, secs, nsecs int) *Lunar
- func (l *Lunar) AnimalYear() string
- func (l *Lunar) Convert() *Solar
- func (l Lunar) Copy() *Lunar
- func (l *Lunar) Day() int
- func (l *Lunar) DayStr() string
- func (l *Lunar) Equal(lunar *Lunar) bool
- func (l *Lunar) Festival(fm FestivalMap) (string, error)
- func (l *Lunar) GetTime() time.Time
- func (l *Lunar) Hour() int
- func (l *Lunar) IsLeapMonth() bool
- func (l *Lunar) LeapMonth() int
- func (l *Lunar) Minute() int
- func (l *Lunar) Month() int
- func (l Lunar) MonthFirst() *Lunar
- func (l Lunar) MonthLast() *Lunar
- func (l *Lunar) MonthStr() string
- func (l *Lunar) Nanosecond() int
- func (l *Lunar) Second() int
- func (l *Lunar) SetHour(hour int) *Lunar
- func (l *Lunar) SetMinute(minute int) *Lunar
- func (l *Lunar) SetNanosecond(nanosecond int) *Lunar
- func (l *Lunar) SetSecond(second int) *Lunar
- func (l *Lunar) String() string
- func (l Lunar) Truncate(d time.Duration) *Lunar
- func (l *Lunar) Weekday() time.Weekday
- func (l *Lunar) WeekdayStr() string
- func (l *Lunar) Year() int
- type Solar
- func (s Solar) AddMonth(months int) *Solar
- func (s *Solar) Convert() *Lunar
- func (s *Solar) DiffWithYMD(year, month, day int) int
- func (s *Solar) Equal(solar *Solar) bool
- func (s *Solar) Festival(fm FestivalMap) (string, error)
- func (s *Solar) GanzhiYMD() (year, month, day string)
- func (s *Solar) GetTime() time.Time
- func (s *Solar) String() string
- func (s Solar) Truncate(d time.Duration) *Solar
Constants ¶
const ( // MinYear smallest year of support MinYear = 1900 // MaxYear largest year of support MaxYear = 2050 )
Variables ¶
var ( SolarFestivals = FestivalMap{ "0101": "元旦", "0214": "情人节", "0308": "妇女节", "0312": "植树节", "0401": "愚人节", "0422": "地球日", "0501": "劳动节", "0504": "青年节", "0531": "无烟日", "0601": "儿童节", "0606": "爱眼日", "0701": "建党日", "0707": "抗战纪念日", "0801": "建军节", "0910": "教师节", "0918": "九·一八事变纪念日", "1001": "国庆节", "1031": "万圣节", "1111": "光棍节", "1201": "艾滋病日", "1213": "南京大屠杀纪念日", "1224": "平安夜", "1225": "圣诞节", } LunarFestivals = FestivalMap{ "0101": "春节", "0115": "元宵节", "0202": "龙抬头", "0505": "端午节", "0707": "七夕", "0715": "中元节", "0815": "中秋节", "0909": "重阳节", "1208": "腊八节", "1223": "小年", "0100": "除夕", } )
var ( // 1900 2月春分后为 庚子年 GanTable = []string{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"} ZhiTable = []string{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"} AnimalTable = []string{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"} )
var ( // CST CST China Standard Time UT 8:00 CST = time.FixedZone("CST", 3600*8) )
var JieQiCTable = [2][24]float64{
{6.11, 20.84, 4.6295, 19.4599, 6.3826, 21.4155, 5.59, 20.888, 6.318, 21.86,
6.5, 22.2, 7.928, 23.65, 8.35, 23.95, 8.44, 23.822, 9.098, 24.218, 8.218, 23.08, 7.9, 22.6},
{5.4055, 20.12, 3.87, 18.73, 5.63, 20.646, 4.81, 20.1, 5.52, 21.04, 5.678,
21.37, 7.108, 22.83, 7.5, 23.13, 7.646, 23.042, 8.318, 23.438, 7.438, 22.36, 7.18, 21.94},
}
var JieQiTable = []string{
"小寒", "大寒", "立春", "雨水", "惊蛰", "春分",
"清明", "谷雨", "立夏", "小满", "芒种", "夏至",
"小暑", "大暑", "立秋", "处暑", "白露", "秋分",
"寒露", "霜降", "立冬", "小雪", "大雪", "冬至",
}
var JieQiTableBase = []int{4, 19, 3, 18, 4, 19, 4, 19, 4, 20, 4, 20, 6, 22, 6, 22, 6, 22, 7, 22, 6, 21, 6, 21}
var JieQiTableIdx = "" /* 202-byte string literal not displayed */
var JieQiTableOffset = "" /* 1656-byte string literal not displayed */
var LunarZero = NewLunar(MinYear, 1, 1, 0, 0, 0, 0, false)
LunarZero lunar zero time.
Functions ¶
func IsLunarZero ¶
IsLunarZero judge whether the lunar time is equal to lunar zero time.
func JieQisOfYear ¶
func LeapMonth ¶
LeapMonth which month leaps in this year? return 1-12(if there is one) or 0(no leap month).
func LunarDayString ¶
LunarDayString used Only by Lunar Object
func LunarMonthDays ¶
LunarMonthDays the days of the m-th month of this year.
func LunarMonthString ¶
LunarMonthString used Only by Lunar Object
func LunarYearString ¶
LunarYearString used Only by Lunar Object
func SolarMonthDays ¶
SolarMonthDays the days of the m-th month of this year.
func SplitDuration ¶
SplitDuration split duration, accurate to second.
Types ¶
type FestivalMap ¶
func NewFestivalMap ¶
func NewFestivalMap() FestivalMap
func NewFestivalsFromFile ¶
func NewFestivalsFromFile(filename string) FestivalMap
func (FestivalMap) Add ¶
func (fm FestivalMap) Add(key, val string)
func (FestivalMap) Del ¶
func (fm FestivalMap) Del(key string)
func (FestivalMap) SaveToFile ¶
func (fm FestivalMap) SaveToFile(filename string) error
type Lunar ¶
type Lunar struct {
// contains filtered or unexported fields
}
Lunar structure
func NewLunarTime ¶
NewLunarTime creates a lunar time from time.Time.
func (*Lunar) Festival ¶
func (l *Lunar) Festival(fm FestivalMap) (string, error)
Festival returns festival.
func (*Lunar) IsLeapMonth ¶
IsLeapMonth returns whether it is leap month.
func (Lunar) MonthFirst ¶
MonthFirst returns lunar time of the month 1 day.
func (*Lunar) SetNanosecond ¶
SetNanosecond sets nanosecond. NOTE: nanosecond range [0:999999999].
func (Lunar) Truncate ¶
Truncate returns the result of rounding t down to a multiple of d (since the zero time). If d <= 0, Truncate returns t unchanged.
Truncate operates on the time as an absolute duration since the zero time; it does not operate on the presentation form of the time. Thus, Truncate(Hour) may return a time with a non-zero minute, depending on the time's Location.
type Solar ¶
Solar structure
func NewSolarTime ¶
NewSolarTime creates a solar time from time.Time.
func (*Solar) DiffWithYMD ¶
DiffWithYMD returns the number of days past the current time.
func (*Solar) Festival ¶
func (s *Solar) Festival(fm FestivalMap) (string, error)
Festival returns festival.
func (Solar) Truncate ¶
Truncate returns the result of rounding t down to a multiple of d (since the zero time). If d <= 0, Truncate returns t unchanged.
Truncate operates on the time as an absolute duration since the zero time; it does not operate on the presentation form of the time. Thus, Truncate(Hour) may return a time with a non-zero minute, depending on the time's Location.