Name Description Size
astronomy.rs This file contains important structs and functions relating to location, time, and astronomy; these are intended for calender calculations and based off _Calendrical Calculations_ by Reingold & Dershowitz. TODO(#3709): Address inconcistencies with existing ICU code for extreme dates. 121666
chinese_based.rs 33733
coptic.rs 1578
error.rs 1079
ethiopian.rs 1288
hebrew.rs 23502
hebrew_keviyah.rs Alternate, more efficient structures for working with the Hebrew Calendar using the keviyah and Four Gates system The main entry point for this code is [`YearInfo::compute_for()`] and [`YearInfo::year_containing_rd()`], which will efficiently calculate certain information about a Hebrew year, given the Hebrew year or a date that falls within it, and produce it as a [`YearInfo`]. From there, you can compute additional information via [`YearInfo::new_year()`] and by accessing the methods on [`YearInfo::keviyah`]. # How this code works: ## How the Hebrew Calendar works The Hebrew calendar is a lunisolar calendar following a Metonic cycle: every 19 years, the pattern of leap years repeats. However, the precise month lengths vary from cycle to cycle: There are a handful of corrections performed to ensure that: - The lunar conjunction happens on or before the first day of the month - Yom Kippur is not before or after the Sabbath - Hoshana Rabbah is not on the Sabbath These corrections can be done using systematic calculations, which this code attempts to efficiently perform. ## Molad A molad is the time of a conjunction, the moment when the new moon occurs. The "Molad Tishrei" is the conjunction corresponding to the month Tishrei, the first month, so it is the molad that starts the new year. In this file we'll typically use "molad" to refer to the molad Tishrei of a year. The Hebrew calendar does not always start on the day of the molad Tishrei: it may be postponed one or two days. However, the time in the week that the molad occurs is sufficient to know when it gets postponed to. ## Keviyah See also: the [`Keviyah`] type. This is the core concept being used here. Everything you need to know about the characteristics of a hebrew year can be boiled down to a notion called the "keviyah" of a year. This encapsulates three bits of information: - What day of the week the year starts on - What the month lengths are - What day of the week Passover starts on. While this seems like many possible combinations, only fourteen of them are possible. Knowing the Keviyah of the year you can understand exactly what the lengths of each month are. Furthermore, if you know the week the year falls in, you can additionally understand what the precise day of the new year is. [`YearInfo`] encapsulates these two pieces of information: the [`Keviyah`] and the number of weeks since the epoch of the Hebrew calendar. ## The Four Gates table This is an efficient lookup based way of calculating the [`Keviyah`] for a year. In the Metonic cycle, there are four broad types of year: leap years, years preceding leap years, years succeeding leap years, and years sandwiched between leap years. For each of these year types, there is a partitioning of the week into seven segments, and the [`Keviyah`] of that year depends on which segment the molad falls in. So to calculate the [`Keviyah`] of a year, we can calculate its molad, pick the right partitioning based on the year type, and see where the molad falls in that table. 42467
helpers.rs 9478
islamic.rs 19045
iso.rs 3660
julian.rs 4280
lib.rs Calendrical calculations This crate implements algorithms from Calendrical Calculations by Reingold & Dershowitz, Cambridge University Press, 4th edition (2018) as needed by [ICU4X](https://github.com/unicode-org/icu4x). Most of these algorithms can be found as lisp code in the book or [on GithHub](https://github.com/EdReingold/calendar-code2/blob/main/calendar.l). The primary purpose of this crate is use by ICU4X, however if non-ICU4X users need this we are happy to add more structure to this crate as needed. 2169
persian.rs 8384
rata_die.rs 5387