Documentation
¶
Overview ¶
JM: Chapter 9, Jewish and Moslem Calendars.
The Jewish calendar routines are implemented as a monolithic function, because computations of the various results build off of common intermediate results.
The Moslem calendar routines break down nicely into some separate functions.
Included in these are two functions that convert between Gregorian and Julian calendar days without going through Julian day (JD). As such, I suppose, these or similar routines are not in chapter 7, Julian Day. Package base might also be a suitable place for these, but I'm not sure they are used anywhere else in the book. Anyway, they have the quirk that they are not direct inverses: JulianToGregorian returns the day number of the day of the Gregorian year, but GregorianToJulian wants the Gregorian month and day of month as input.
Index ¶
- func GregorianToJulian(y, m, d int) (jy, jm, jd int)
- func JewishCalendar(y int) (A, mP, dP, mNY, dNY, months, days int)
- func JulianToGregorian(y, dn int) (gY, gM, gD int)
- func JulianToMoslem(y, m, d int) (my, mm, md int)
- func MoslemLeapYear(y int) bool
- func MoslemToJulian(y, m, d int) (jY, jDN int)
- type MMonth
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GregorianToJulian ¶
GregorianToJulian takes a year, month, and day of the Gregorian calendar and returns the equivalent year, month, and day of the Julian calendar.
Example ¶
package main
import (
"fmt"
"time"
"github.com/mooncaker816/learnmeeus/v3/jm"
)
func main() {
// Example 9.c, p. 76, conversion to Julian Calendar.
y, m, d := jm.GregorianToJulian(1991, 8, 13)
fmt.Println(y, time.Month(m), d, "Julian")
}
Output: 1991 July 31 Julian
func JewishCalendar ¶
JewishCalendar returns interesting dates and facts about a given year.
Input is a Julian or Gregorian year.
Outputs:
A: Year number in the Jewish Calendar mP: Month number of Pesach. dP: Day number of Pesach. mNY: Month number of the Jewish new year. dNY: Day number of the Jewish new year. months: Number of months in this year. days: Number of days in this year.
Example ¶
package main
import (
"fmt"
"time"
"github.com/mooncaker816/learnmeeus/v3/jm"
)
func main() {
// Example 9.a, p. 73.
A, mP, dP, mNY, dNY, months, days := jm.JewishCalendar(1990)
fmt.Println("Jewish Year:", A)
fmt.Println("Pesach: ", time.Month(mP), dP)
fmt.Println("New Year: ", time.Month(mNY), dNY)
fmt.Println("Months: ", months)
fmt.Println("Days: ", days)
}
Output: Jewish Year: 5750 Pesach: April 10 New Year: September 20 Months: 12 Days: 354
func JulianToGregorian ¶
JulianToGregorian converts a Julian calendar year and day number to a year, month, and day in the Gregorian calendar.
Example ¶
package main
import (
"fmt"
"time"
"github.com/mooncaker816/learnmeeus/v3/jm"
)
func main() {
// Example 9.b, p. 75, conversion to Gregorian.
y, m, d := jm.JulianToGregorian(2000, 84)
fmt.Println(d, time.Month(m), y)
}
Output: 6 April 2000
func JulianToMoslem ¶
JulianToMoslem takes a year, month, and day of the Julian calendar and returns the equivalent year, month, and day of the Moslem calendar.
Example ¶
package main
import (
"fmt"
"github.com/mooncaker816/learnmeeus/v3/jm"
)
func main() {
// Example 9.c, p. 76, final output.
y, m, d := jm.JulianToMoslem(1991, 7, 31)
fmt.Println(d, jm.MMonth(m), "of A.H.", y)
}
Output: 2 Ṣafar of A.H. 1412
func MoslemLeapYear ¶
MoslemLeapYear returns true if year y of the Moslem calendar is a leap year.
Example ¶
package main
import (
"fmt"
"github.com/mooncaker816/learnmeeus/v3/jm"
)
func main() {
// Example 9.b, p. 75, indication of leap year.
if jm.MoslemLeapYear(1421) {
fmt.Println("Moslem year 1421 is a leap year of 355 days.")
} else {
fmt.Println("Moslem year 1421 is a common year of 354 days.")
}
}
Output: Moslem year 1421 is a common year of 354 days.
func MoslemToJulian ¶
MoslemToJulian converts a Moslem calandar date to a Julian year and day number.
Example ¶
package main
import (
"fmt"
"github.com/mooncaker816/learnmeeus/v3/jm"
)
func main() {
// Example 9.b, p. 75, conversion to Julian.
y, dn := jm.MoslemToJulian(1421, 1, 1)
fmt.Println(y, dn)
}
Output: 2000 84