use golang timezone
This commit is contained in:
		
							parent
							
								
									1c4397c9dc
								
							
						
					
					
						commit
						681dea1fb5
					
				@ -199,8 +199,8 @@ func JDE2DateByZone(JD float64, tz *time.Location) time.Time {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	tms := (Days - math.Floor(Days)) * 24 * 3600
 | 
						tms := (Days - math.Floor(Days)) * 24 * 3600
 | 
				
			||||||
	Days = math.Floor(Days)
 | 
						Days = math.Floor(Days)
 | 
				
			||||||
	dates := time.Date(int(Years), time.Month(int(Months)), int(Days), 0, 0, 0, 0, tz)
 | 
						dates := time.Date(int(Years), time.Month(int(Months)), int(Days), 0, 0, 0, 0, time.UTC)
 | 
				
			||||||
	dates = time.Unix(dates.Unix()+int64(tms), int64((tms-math.Floor(tms))*1000000000))
 | 
						dates = time.Unix(dates.Unix()+int64(tms), int64((tms-math.Floor(tms))*1000000000)).In(tz)
 | 
				
			||||||
	return dates
 | 
						return dates
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -55,8 +55,9 @@ func ChineseLunar(date time.Time) (int, int, bool, string) {
 | 
				
			|||||||
// 例:计算己亥猪年腊月三十日对应的公历(即2020年1月24日)
 | 
					// 例:计算己亥猪年腊月三十日对应的公历(即2020年1月24日)
 | 
				
			||||||
// 由于农历还未到鼠年,故应当传入Solar(2019,12,30,false)
 | 
					// 由于农历还未到鼠年,故应当传入Solar(2019,12,30,false)
 | 
				
			||||||
func Solar(year, month, day int, leap bool) time.Time {
 | 
					func Solar(year, month, day int, leap bool) time.Time {
 | 
				
			||||||
	jde := basic.GetSolar(year, month, day, leap)
 | 
						jde := basic.GetSolar(year, month, day, leap) - 8.0/24.0
 | 
				
			||||||
	return JDE2Date(jde)
 | 
						zone := time.FixedZone("CST", 8*3600)
 | 
				
			||||||
 | 
						return basic.JDE2DateByZone(jde, zone)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GanZhi 返回传入年份对应的干支
 | 
					// GanZhi 返回传入年份对应的干支
 | 
				
			||||||
@ -66,14 +67,14 @@ func GanZhi(year int) string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// JieQi 返回传入年份、节气对应的北京时间节气时间
 | 
					// JieQi 返回传入年份、节气对应的北京时间节气时间
 | 
				
			||||||
func JieQi(year, term int) time.Time {
 | 
					func JieQi(year, term int) time.Time {
 | 
				
			||||||
	calcJde := basic.GetJQTime(year, term) + 8.00/24.00
 | 
						calcJde := basic.GetJQTime(year, term)
 | 
				
			||||||
	zone := time.FixedZone("CST", 8*3600)
 | 
						zone := time.FixedZone("CST", 8*3600)
 | 
				
			||||||
	return basic.JDE2DateByZone(calcJde, zone)
 | 
						return basic.JDE2DateByZone(calcJde, zone)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WuHou 返回传入年份、物候对应的北京时间物候时间
 | 
					// WuHou 返回传入年份、物候对应的北京时间物候时间
 | 
				
			||||||
func WuHou(year, term int) time.Time {
 | 
					func WuHou(year, term int) time.Time {
 | 
				
			||||||
	calcJde := basic.GetWHTime(year, term) + 8.00/24.00
 | 
						calcJde := basic.GetWHTime(year, term)
 | 
				
			||||||
	zone := time.FixedZone("CST", 8*3600)
 | 
						zone := time.FixedZone("CST", 8*3600)
 | 
				
			||||||
	return basic.JDE2DateByZone(calcJde, zone)
 | 
						return basic.JDE2DateByZone(calcJde, zone)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										73
									
								
								moon/moon.go
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								moon/moon.go
									
									
									
									
									
								
							@ -33,66 +33,66 @@ func SeeLo(date time.Time) float64 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SeeRa 月亮视赤经(站心)
 | 
					// SeeRa 月亮视赤经(站心)
 | 
				
			||||||
// jde,世界时UTC
 | 
					// date, 时间
 | 
				
			||||||
// lon, 经度
 | 
					// lon, 经度
 | 
				
			||||||
// lat, 纬度
 | 
					// lat, 纬度
 | 
				
			||||||
// timezone, 时区
 | 
					 | 
				
			||||||
// 返回站心坐标
 | 
					// 返回站心坐标
 | 
				
			||||||
func SeeRa(date time.Time, lon, lat, timezone float64) float64 {
 | 
					func SeeRa(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.HMoonSeeRa(basic.TD2UT(jde, true), lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.HMoonSeeRa(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SeeDec 月亮视赤纬(站心)
 | 
					// SeeDec 月亮视赤纬(站心)
 | 
				
			||||||
// jde,世界时UTC
 | 
					// date, 时间
 | 
				
			||||||
// lon, 经度
 | 
					// lon, 经度
 | 
				
			||||||
// lat, 纬度
 | 
					// lat, 纬度
 | 
				
			||||||
// timezone, 时区
 | 
					 | 
				
			||||||
// 返回站心坐标
 | 
					// 返回站心坐标
 | 
				
			||||||
func SeeDec(date time.Time, lon, lat, timezone float64) float64 {
 | 
					func SeeDec(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.HMoonSeeDec(basic.TD2UT(jde, true), lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.HMoonSeeDec(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SeeRaDec 月亮视赤纬(站心)
 | 
					// SeeRaDec 月亮视赤纬(站心)
 | 
				
			||||||
// jde,世界时UTC
 | 
					// date, 本地时间
 | 
				
			||||||
// lon, 经度
 | 
					// lon, 经度
 | 
				
			||||||
// lat, 纬度
 | 
					// lat, 纬度
 | 
				
			||||||
// timezone, 时区
 | 
					 | 
				
			||||||
// 返回站心坐标
 | 
					// 返回站心坐标
 | 
				
			||||||
func SeeRaDec(date time.Time, lon, lat, timezone float64) (float64, float64) {
 | 
					func SeeRaDec(date time.Time, lon, lat float64) (float64, float64) {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.HMoonSeeRaDec(basic.TD2UT(jde, true), lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.HMoonSeeRaDec(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HourAngle 月亮时角
 | 
					// HourAngle 月亮时角
 | 
				
			||||||
//  date, 世界时(忽略此处时区)
 | 
					//  date, 世界时(忽略此处时区)
 | 
				
			||||||
//  lon,经度,东正西负
 | 
					//  lon,经度,东正西负
 | 
				
			||||||
//  lat,纬度,北正南负
 | 
					//  lat,纬度,北正南负
 | 
				
			||||||
//  timezone,时区,东正西负
 | 
					func HourAngle(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
func HourAngle(date time.Time, lon, lat, timezone float64) float64 {
 | 
					 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.MoonTimeAngle(jde, lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.MoonTimeAngle(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Azimuth 月亮方位角
 | 
					// Azimuth 月亮方位角
 | 
				
			||||||
//  date, 世界时(忽略此处时区)
 | 
					//  date, 世界时(忽略此处时区)
 | 
				
			||||||
//  lon,经度,东正西负
 | 
					//  lon,经度,东正西负
 | 
				
			||||||
//  lat,纬度,北正南负
 | 
					//  lat,纬度,北正南负
 | 
				
			||||||
//  timezone,时区,东正西负
 | 
					func Azimuth(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
func Azimuth(date time.Time, lon, lat, timezone float64) float64 {
 | 
					 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.HMoonAngle(jde, lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.HMoonAngle(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Zenith 月亮高度角
 | 
					// Zenith 月亮高度角
 | 
				
			||||||
//  date, 世界时(忽略此处时区)
 | 
					//  date, 世界时(忽略此处时区)
 | 
				
			||||||
//  lon,经度,东正西负
 | 
					//  lon,经度,东正西负
 | 
				
			||||||
//  lat,纬度,北正南负
 | 
					//  lat,纬度,北正南负
 | 
				
			||||||
//  timezone,时区,东正西负
 | 
					 | 
				
			||||||
func Zenith(date time.Time, lon, lat, timezone float64) float64 {
 | 
					func Zenith(date time.Time, lon, lat, timezone float64) float64 {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.HMoonHeight(jde, lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.HMoonHeight(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CulminationTime 月亮中天时间
 | 
					// CulminationTime 月亮中天时间
 | 
				
			||||||
@ -100,9 +100,10 @@ func Zenith(date time.Time, lon, lat, timezone float64) float64 {
 | 
				
			|||||||
//  lon,经度,东正西负
 | 
					//  lon,经度,东正西负
 | 
				
			||||||
//  lat,纬度,北正南负
 | 
					//  lat,纬度,北正南负
 | 
				
			||||||
//  timezone,时区,东正西负
 | 
					//  timezone,时区,东正西负
 | 
				
			||||||
func CulminationTime(date time.Time, lon, lat, timezone float64) float64 {
 | 
					func CulminationTime(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	return basic.GetMoonTZTime(jde, lon, lat, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						return basic.GetMoonTZTime(jde, lon, lat, float64(loc)/3600.0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RiseTime 月亮升起时间
 | 
					// RiseTime 月亮升起时间
 | 
				
			||||||
@ -110,9 +111,11 @@ func CulminationTime(date time.Time, lon, lat, timezone float64) float64 {
 | 
				
			|||||||
//  lon,经度,东正西负
 | 
					//  lon,经度,东正西负
 | 
				
			||||||
//  lat,纬度,北正南负
 | 
					//  lat,纬度,北正南负
 | 
				
			||||||
//  timezone,时区,东正西负
 | 
					//  timezone,时区,东正西负
 | 
				
			||||||
func RiseTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time, error) {
 | 
					func RiseTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	aeroFloat := 0.00
 | 
						aeroFloat := 0.00
 | 
				
			||||||
	if aero {
 | 
						if aero {
 | 
				
			||||||
		aeroFloat = 1
 | 
							aeroFloat = 1
 | 
				
			||||||
@ -135,9 +138,11 @@ func RiseTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time,
 | 
				
			|||||||
//  lon,经度,东正西负
 | 
					//  lon,经度,东正西负
 | 
				
			||||||
//  lat,纬度,北正南负
 | 
					//  lat,纬度,北正南负
 | 
				
			||||||
//  timezone,时区,东正西负
 | 
					//  timezone,时区,东正西负
 | 
				
			||||||
func DownTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time, error) {
 | 
					func DownTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	aeroFloat := 0.00
 | 
						aeroFloat := 0.00
 | 
				
			||||||
	if aero {
 | 
						if aero {
 | 
				
			||||||
		aeroFloat = 1
 | 
							aeroFloat = 1
 | 
				
			||||||
@ -163,23 +168,27 @@ func Phase(date time.Time) float64 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ShuoYue 朔月
 | 
					// ShuoYue 朔月
 | 
				
			||||||
func ShuoYue(year float64) float64 {
 | 
					func ShuoYue(year float64) time.Time {
 | 
				
			||||||
	return basic.CalcMoonSH(year, 0)
 | 
						jde := basic.TD2UT(basic.CalcMoonSH(year, 0), false)
 | 
				
			||||||
 | 
						return basic.JDE2DateByZone(jde, time.UTC)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WangYue 望月
 | 
					// WangYue 望月
 | 
				
			||||||
func WangYue(year float64) float64 {
 | 
					func WangYue(year float64) time.Time {
 | 
				
			||||||
	return basic.CalcMoonSH(year, 1)
 | 
						jde := basic.TD2UT(basic.CalcMoonSH(year, 1), false)
 | 
				
			||||||
 | 
						return basic.JDE2DateByZone(jde, time.UTC)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ShangXianYue 上弦月
 | 
					// ShangXianYue 上弦月
 | 
				
			||||||
func ShangXianYue(year float64) float64 {
 | 
					func ShangXianYue(year float64) time.Time {
 | 
				
			||||||
	return basic.CalcMoonXH(year, 0)
 | 
						jde := basic.TD2UT(basic.CalcMoonXH(year, 0), false)
 | 
				
			||||||
 | 
						return basic.JDE2DateByZone(jde, time.UTC)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// XiaXianYue 下弦月
 | 
					// XiaXianYue 下弦月
 | 
				
			||||||
func XiaXianYue(year float64) float64 {
 | 
					func XiaXianYue(year float64) time.Time {
 | 
				
			||||||
	return basic.CalcMoonXH(year, 1)
 | 
						jde := basic.TD2UT(basic.CalcMoonXH(year, 1), false)
 | 
				
			||||||
 | 
						return basic.JDE2DateByZone(jde, time.UTC)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EarthDistance 日地距离
 | 
					// EarthDistance 日地距离
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										59
									
								
								sun/sun.go
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								sun/sun.go
									
									
									
									
									
								
							@ -27,15 +27,16 @@ var (
 | 
				
			|||||||
// date,取日期,时区忽略
 | 
					// date,取日期,时区忽略
 | 
				
			||||||
// lon,经度,东正西负
 | 
					// lon,经度,东正西负
 | 
				
			||||||
// lat,纬度,北正南负
 | 
					// lat,纬度,北正南负
 | 
				
			||||||
// timezone,时区,东正西负
 | 
					 | 
				
			||||||
// aero,true时进行大气修正
 | 
					// aero,true时进行大气修正
 | 
				
			||||||
func RiseTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time, error) {
 | 
					func RiseTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	var aeroFloat float64
 | 
						var aeroFloat float64
 | 
				
			||||||
	if aero {
 | 
						if aero {
 | 
				
			||||||
		aeroFloat = 1
 | 
							aeroFloat = 1
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	riseJde := basic.GetSunRiseTime(jde, lon, lat, timezone, aeroFloat)
 | 
						riseJde := basic.GetSunRiseTime(jde, lon, lat, timezone, aeroFloat)
 | 
				
			||||||
	if riseJde == -2 {
 | 
						if riseJde == -2 {
 | 
				
			||||||
		err = ERR_SUN_NEVER_RISE
 | 
							err = ERR_SUN_NEVER_RISE
 | 
				
			||||||
@ -47,18 +48,19 @@ func RiseTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SunDownTime 太阳落下时间
 | 
					// SunDownTime 太阳落下时间
 | 
				
			||||||
// date,取日期,时区忽略
 | 
					// date,当地时区日期,务必做时区修正
 | 
				
			||||||
// lon,经度,东正西负
 | 
					// lon,经度,东正西负
 | 
				
			||||||
// lat,纬度,北正南负
 | 
					// lat,纬度,北正南负
 | 
				
			||||||
// timezone,时区,东正西负
 | 
					 | 
				
			||||||
// aero,true时进行大气修正
 | 
					// aero,true时进行大气修正
 | 
				
			||||||
func DownTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time, error) {
 | 
					func DownTime(date time.Time, lon, lat float64, aero bool) (time.Time, error) {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	var aeroFloat float64
 | 
						var aeroFloat float64
 | 
				
			||||||
	if aero {
 | 
						if aero {
 | 
				
			||||||
		aeroFloat = 1
 | 
							aeroFloat = 1
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	downJde := basic.GetSunDownTime(jde, lon, lat, timezone, aeroFloat)
 | 
						downJde := basic.GetSunDownTime(jde, lon, lat, timezone, aeroFloat)
 | 
				
			||||||
	if downJde == -2 {
 | 
						if downJde == -2 {
 | 
				
			||||||
		err = ERR_SUN_NEVER_RISE
 | 
							err = ERR_SUN_NEVER_RISE
 | 
				
			||||||
@ -70,14 +72,15 @@ func DownTime(date time.Time, lon, lat, timezone float64, aero bool) (time.Time,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MorningTwilight 晨朦影
 | 
					// MorningTwilight 晨朦影
 | 
				
			||||||
// date,取日期,时区忽略
 | 
					// date,当地时区日期
 | 
				
			||||||
// lon,经度,东正西负
 | 
					// lon,经度,东正西负
 | 
				
			||||||
// lat,纬度,北正南负
 | 
					// lat,纬度,北正南负
 | 
				
			||||||
// timezone,时区,东正西负
 | 
					 | 
				
			||||||
// angle,朦影角度:可选-6 -12 -18(民用、航海、天文)
 | 
					// angle,朦影角度:可选-6 -12 -18(民用、航海、天文)
 | 
				
			||||||
func MorningTwilight(date time.Time, lon, lat, timezone, angle float64) (time.Time, error) {
 | 
					func MorningTwilight(date time.Time, lon, lat, angle float64) (time.Time, error) {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	calcJde := basic.GetAsaTime(jde, lon, lat, timezone, angle)
 | 
						calcJde := basic.GetAsaTime(jde, lon, lat, timezone, angle)
 | 
				
			||||||
	if calcJde == -2 {
 | 
						if calcJde == -2 {
 | 
				
			||||||
		err = ERR_TWILIGHT_NOT_EXISTS
 | 
							err = ERR_TWILIGHT_NOT_EXISTS
 | 
				
			||||||
@ -89,14 +92,15 @@ func MorningTwilight(date time.Time, lon, lat, timezone, angle float64) (time.Ti
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EveningTwilight 昏朦影
 | 
					// EveningTwilight 昏朦影
 | 
				
			||||||
// date,取日期,时区忽略
 | 
					// date,当地时区日期
 | 
				
			||||||
// lon,经度,东正西负
 | 
					// lon,经度,东正西负
 | 
				
			||||||
// lat,纬度,北正南负
 | 
					// lat,纬度,北正南负
 | 
				
			||||||
// timezone,时区,东正西负
 | 
					 | 
				
			||||||
// angle,朦影角度:可选-6 -12 -18(民用、航海、天文)
 | 
					// angle,朦影角度:可选-6 -12 -18(民用、航海、天文)
 | 
				
			||||||
func EveningTwilight(date time.Time, lon, lat, timezone, angle float64) (time.Time, error) {
 | 
					func EveningTwilight(date time.Time, lon, lat, angle float64) (time.Time, error) {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	//不需要进行力学时转换,会在GetBanTime中转换
 | 
						//不需要进行力学时转换,会在GetBanTime中转换
 | 
				
			||||||
	calcJde := basic.GetBanTime(jde, lon, lat, timezone, angle)
 | 
						calcJde := basic.GetBanTime(jde, lon, lat, timezone, angle)
 | 
				
			||||||
	if calcJde == -2 {
 | 
						if calcJde == -2 {
 | 
				
			||||||
@ -209,44 +213,49 @@ func EquationTime(date time.Time) float64 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HourAngle 太阳时角
 | 
					// HourAngle 太阳时角
 | 
				
			||||||
// 返回给定经纬度、对应timezone时区date时刻的太阳时角(注意,date本身的时区将默认舍去)
 | 
					// 返回给定经纬度、对应date时区date时刻的太阳时角(
 | 
				
			||||||
func HourAngle(date time.Time, lon, lat, timezone float64) float64 {
 | 
					func HourAngle(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	return basic.SunTimeAngle(jde, lon, lat, timezone)
 | 
						return basic.SunTimeAngle(jde, lon, lat, timezone)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Azimuth 太阳方位角
 | 
					// Azimuth 太阳方位角
 | 
				
			||||||
// 返回给定经纬度、对应timezone时区date时刻的太阳方位角(正北为0,向东增加)
 | 
					// 返回给定经纬度、对应date时区date时刻的太阳方位角(正北为0,向东增加)
 | 
				
			||||||
//(注意,date本身的时区将默认舍去)
 | 
					func Azimuth(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
func Azimuth(date time.Time, lon, lat, timezone float64) float64 {
 | 
					 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	return basic.SunAngle(jde, lon, lat, timezone)
 | 
						return basic.SunAngle(jde, lon, lat, timezone)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Zenith 太阳高度角
 | 
					// Zenith 太阳高度角
 | 
				
			||||||
// 返回给定经纬度、对应timezone时区date时刻的太阳高度角
 | 
					// 返回给定经纬度、对应date时区date时刻的太阳高度角
 | 
				
			||||||
//(注意,date本身的时区将默认舍去)
 | 
					func Zenith(date time.Time, lon, lat float64) float64 {
 | 
				
			||||||
func Zenith(date time.Time, lon, lat, timezone float64) float64 {
 | 
					 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
 | 
						_, loc := date.Zone()
 | 
				
			||||||
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
	return basic.SunHeight(jde, lon, lat, timezone)
 | 
						return basic.SunHeight(jde, lon, lat, timezone)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CulminationTime 太阳中天时间
 | 
					// CulminationTime 太阳中天时间
 | 
				
			||||||
// 返回给定经纬度、对应timezone时区date时刻的太阳中天日期
 | 
					// 返回给定经纬度、对应date时区date时刻的太阳中天日期
 | 
				
			||||||
//(注意,date本身的时区将默认舍去,返回的时间时区应当为传入的timezone)
 | 
					func CulminationTime(date time.Time, lon float64) time.Time {
 | 
				
			||||||
func CulminationTime(date time.Time, lon, timezone float64) time.Time {
 | 
					 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date)
 | 
				
			||||||
	if jde-math.Floor(jde) > 0.5 {
 | 
						if jde-math.Floor(jde) > 0.5 {
 | 
				
			||||||
		jde++
 | 
							jde++
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	calcJde := basic.GetSunTZTime(jde, lon, timezone)
 | 
						_, loc := date.Zone()
 | 
				
			||||||
	return basic.JDE2Date(calcJde)
 | 
						timezone := float64(loc) / 3600.0
 | 
				
			||||||
 | 
						calcJde := basic.GetSunTZTime(jde, lon, timezone) - timezone/24.00
 | 
				
			||||||
 | 
						return basic.JDE2DateByZone(calcJde, date.Location())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EarthDistance 日地距离
 | 
					// EarthDistance 日地距离
 | 
				
			||||||
// 返回date对应UTC世界时日地距离
 | 
					// 返回date对应UTC世界时日地距离
 | 
				
			||||||
func EarthDistance(date time.Time) float64 {
 | 
					func EarthDistance(date time.Time) float64 {
 | 
				
			||||||
	jde := basic.Date2JDE(date)
 | 
						jde := basic.Date2JDE(date.UTC())
 | 
				
			||||||
	jde = basic.TD2UT(jde, true)
 | 
						jde = basic.TD2UT(jde, true)
 | 
				
			||||||
	return basic.EarthAway(jde)
 | 
						return basic.EarthAway(jde)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user