You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
astro/astro.go

191 lines
3.9 KiB
Go

5 years ago
package astro
import (
"errors"
"time"
"b612.me/astro/basic"
)
/*
*/
func NowJDE() float64 {
return basic.GetNowJDE()
}
/*
*/
func Date2JDE(date time.Time) float64 {
day := float64(date.Day()) + float64(date.Hour())/24.0 + float64(date.Minute())/24.0/60.0 + float64(date.Second())/24.0/3600.0 + float64(date.Nanosecond())/1000000000.0/3600.0/24.0
return basic.JDECalc(date.Year(), int(date.Month()), day)
}
/*
*/
func JDE2Date(jde float64) time.Time {
return basic.JDE2Date(jde)
}
/*
*/
func Lunar(year, month, day int) (int, int, bool, string) {
return basic.GetLunar(year, month, day)
}
/*
*/
func Solar(year, month, day int, leap bool) time.Time {
jde := basic.GetSolar(year, month, day, leap)
return JDE2Date(jde)
}
/*
jde0 JDE
lon西
lat
timezone西
aerotrue
*/
func SunRiseTime(jde, lon, lat, timezone float64, aero bool) (time.Time, error) {
var err error = nil
tz := 0.00
if aero {
tz = 1
}
tm := basic.GetSunRiseTime(jde, lon, lat, timezone, tz)
if tm == -2 {
err = errors.New("极夜")
}
if tm == -1 {
err = errors.New("极昼")
}
return JDE2Date(tm), err
}
/*
jde0 JDE
lon西
lat
timezone西
aerotrue
*/
func SunDownTime(jde, lon, lat, timezone float64, aero bool) (time.Time, error) {
var err error = nil
tz := 0.00
if aero {
tz = 1
}
tm := basic.GetSunDownTime(jde, lon, lat, timezone, tz)
if tm == -2 {
err = errors.New("极夜")
}
if tm == -1 {
err = errors.New("极昼")
}
return JDE2Date(tm), err
}
/*
jde0 JDE
lon西
lat
timezone西
angle-6 -12 -18
*/
func MorningTwilightTime(jde, lon, lat, timezone, angle float64) (time.Time, error) {
var err error = nil
tm := basic.GetAsaTime(jde, lon, lat, timezone, angle)
if tm == -2 {
err = errors.New("不存在")
}
if tm == -1 {
err = errors.New("不存在")
}
return JDE2Date(tm), err
}
/*
jde0 JDE
lon西
lat
timezone西
angle-6 -12 -18
*/
func EveningTwilightTime(jde, lon, lat, timezone, angle float64) (time.Time, error) {
var err error = nil
tm := basic.GetBanTime(jde, lon, lat, timezone, angle)
if tm == -2 {
err = errors.New("不存在")
}
if tm == -1 {
err = errors.New("不存在")
}
return JDE2Date(tm), err
}
/*
jde0 JDE
lon西
lat
timezone西
aerotrue
*/
func MoonRiseTime(jde, lon, lat, timezone float64, aero bool) (time.Time, error) {
var err error = nil
tz := 0.00
if aero {
tz = 1
}
tm := basic.GetMoonRiseTime(jde, lon, lat, timezone, tz)
if tm == -2 {
err = errors.New("极夜")
}
if tm == -1 {
err = errors.New("极昼")
}
return JDE2Date(tm), err
}
/*
jde0 JDE
lon西
lat
timezone西
aerotrue
*/
func MoonDownTime(jde, lon, lat, timezone float64, aero bool) (time.Time, error) {
var err error = nil
tz := 0.00
if aero {
tz = 1
}
tm := basic.GetMoonDownTime(jde, lon, lat, timezone, tz)
if tm == -2 {
err = errors.New("极夜")
}
if tm == -1 {
err = errors.New("极昼")
}
return JDE2Date(tm), err
}
/*
jdeUTC JDE
*/
func Phase(jde float64) float64 {
return basic.MoonLight(basic.TD2UT(jde, true))
}