Documentation
¶
Overview ¶
Julian: Chapter 7, Julian day.
Under "General remarks", Meeus describes the INT function as used in the book. In some contexts, math.Floor might be suitable, but I think more often, the functions base.FloorDiv or base.FloorDiv64 will be more appropriate. See documentation in package base.
On p. 63, Modified Julian Day is defined. See constant JMod in package base.
See also related functions JulianToGregorian and GregorianToJulian in package jm.
Index ¶
- func CalendarGregorianToJD(y, m int, d float64) float64
- func CalendarJulianToJD(y, m int, d float64) float64
- func DayOfWeek(jd float64) int
- func DayOfYear(y, m, d int, leap bool) int
- func DayOfYearGregorian(y, m, d int) int
- func DayOfYearJulian(y, m, d int) int
- func DayOfYearToCalendar(n int, leap bool) (m, d int)
- func JDToCalendar(jd float64) (year, month int, day float64)
- func JDToTime(jd float64) time.Time
- func LeapYearGregorian(y int) bool
- func LeapYearJulian(y int) bool
- func TimeToJD(t time.Time) float64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalendarGregorianToJD ¶
CalendarGregorianToJD converts a Gregorian year, month, and day of month to Julian day.
Negative years are valid, back to JD 0. The result is not valid for dates before JD 0.
Example (Halley) ¶
package main import ( "fmt" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.c, p. 64. jd1 := julian.CalendarGregorianToJD(1910, 4, 20) jd2 := julian.CalendarGregorianToJD(1986, 2, 9) fmt.Printf("%.0f days\n", jd2-jd1) }
Output: 27689 days
Example (Sputnik) ¶
package main import ( "fmt" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.a, p. 61. jd := julian.CalendarGregorianToJD(1957, 10, 4.81) fmt.Printf("%.2f\n", jd) }
Output: 2436116.31
func CalendarJulianToJD ¶
CalendarJulianToJD converts a Julian year, month, and day of month to Julian day.
Negative years are valid, back to JD 0. The result is not valid for dates before JD 0.
Example ¶
package main import ( "fmt" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.b, p. 61. jd := julian.CalendarJulianToJD(333, 1, 27.5) fmt.Printf("%.1f\n", jd) }
Output: 1842713.0
func DayOfWeek ¶
DayOfWeek determines the day of the week for a given JD.
The value returned is an integer in the range 0 to 6, where 0 represents Sunday. This is the same convention followed in the time package of the Go standard library.
Example ¶
package main import ( "fmt" "time" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.e, p. 65. fmt.Println(time.Weekday(julian.DayOfWeek(2434923.5))) }
Output: Wednesday
func DayOfYear ¶
DayOfYear computes the day number within the year.
This form of the function is not specific to the Julian or Gregorian calendar, but you must tell it whether the year is a leap year.
Example (F) ¶
package main import ( "fmt" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.f, p. 65. fmt.Println(julian.DayOfYear(1978, 11, 14, false)) }
Output: 318
Example (G) ¶
package main import ( "fmt" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.g, p. 65. fmt.Println(julian.DayOfYear(1988, 4, 22, true)) }
Output: 113
func DayOfYearGregorian ¶
DayOfYearGregorian computes the day number within the year of the Gregorian calendar.
func DayOfYearJulian ¶
DayOfYearJulian computes the day number within the year of the Julian calendar.
func DayOfYearToCalendar ¶
DayOfYearToCalendar returns the calendar month and day for a given day of year and leap year status.
func JDToCalendar ¶
JDToCalendar returns the calendar date for the given jd.
Note that this function returns a date in either the Julian or Gregorian Calendar, as appropriate.
Example ¶
package main import ( "fmt" "time" "github.com/soniakeys/meeus/v3/julian" ) func main() { // Example 7.c, p. 64. y, m, d := julian.JDToCalendar(2436116.31) fmt.Printf("%d %s %.2f\n", y, time.Month(m), d) }
Output: 1957 October 4.81
func LeapYearGregorian ¶
LeapYearGregorian returns true if year y in the Gregorian calendar is a leap year.
func LeapYearJulian ¶
LeapYearJulian returns true if year y in the Julian calendar is a leap year.
Types ¶
This section is empty.