julian

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: MIT Imports: 3 Imported by: 11

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalendarGregorianToJD

func CalendarGregorianToJD(y, m int, d float64) float64

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

func CalendarJulianToJD(y, m int, d float64) float64

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

func DayOfWeek(jd float64) int

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

func DayOfYear(y, m, d int, leap bool) int

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

func DayOfYearGregorian(y, m, d int) int

DayOfYearGregorian computes the day number within the year of the Gregorian calendar.

func DayOfYearJulian

func DayOfYearJulian(y, m, d int) int

DayOfYearJulian computes the day number within the year of the Julian calendar.

func DayOfYearToCalendar

func DayOfYearToCalendar(n int, leap bool) (m, d int)

DayOfYearToCalendar returns the calendar month and day for a given day of year and leap year status.

func JDToCalendar

func JDToCalendar(jd float64) (year, month int, day float64)

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 JDToTime

func JDToTime(jd float64) time.Time

JDToTime takes a JD and returns a Go time.Time value.

func LeapYearGregorian

func LeapYearGregorian(y int) bool

LeapYearGregorian returns true if year y in the Gregorian calendar is a leap year.

func LeapYearJulian

func LeapYearJulian(y int) bool

LeapYearJulian returns true if year y in the Julian calendar is a leap year.

func TimeToJD

func TimeToJD(t time.Time) float64

TimeToJD takes a Go time.Time and returns a JD as float64.

Any time zone offset in the time.Time is ignored and the time is treated as UTC.

Types

This section is empty.

Jump to

Keyboard shortcuts

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