gregorian0python.module
fault.time

Gregorian calendar functions and data.

operator
import

callib0
import

centuries_in_cycle
data

centuries_in_cycle = 4

years_in_century
data

years_in_century = 100

years_in_decade
data

years_in_decade = 10

centuries_in_millennium
data

centuries_in_millennium = 10

month_names0
data

month_names = (
	"january",
	"february",
	"march",
	"april",
	"may",
	"june",
	"july",
	"august",
	"september",
	"october",
	"november",
	"december",
)

months_in_year0
data

months_in_year = len(month_names)

month_abbreviations0
data

month_abbreviations = (
	"jan", "feb", "mar",
	"apr", "may", "jun",
	"jul", "aug", "sep",
	"oct", "nov", "dec",
)

month_name_to_number0
data

month_name_to_number = {
	month_names[i] : i for i in range(len(month_names))
}

calendar_year0
data

calendar_year = (
	31, 28, 31, 30,
	31, 30, 31, 31,
	30, 31, 30, 31
)

calendar_leap0
data

calendar_leap = (calendar_year[0], calendar_year[1] + 1) + calendar_year[2:] # Feb29

leap_cycle0
data

leap_cycle = (
	('leap', 1, calendar_leap),
	('years', 3, calendar_year)
)

cycle0
data

cycle = (
	'gregorian-cycle', 1, (
		# First century; normal leap cycle throughout.
		('first-century', 25, leap_cycle),

		# Subsequent three centuries in the cycle.
		# First year in century is leap exception.
		('centuries', 3, (
			('first-year-exception', 4, calendar_year),
			('regular-cycle', 24, leap_cycle),
		)),
	)
)

calendar0
data

calendar = callib.aggregate(cycle)

resolve_by_months0
function

resolve_by_months(months)

resolve_by_days0
function

resolve_by_days(days)

months_in_cycle0
data

months_in_cycle = months_in_year * years_in_century * centuries_in_cycle

r0
data

r = resolve_by_months(months_in_cycle-1)

days_in_cycle0
data

days_in_cycle = r[1] + r[-1]

year_is_leap0
function

year_is_leap(y)

Given a gregorian calendar year, determine whether it is a leap year.

month_from_days0
function

month_from_days(days)

Convert the given number Earth-days to a month in the Gregorian cycle.

NOTE

This does not communicate the remainder of days.

days_from_month0
function

days_from_month(months)

Convert the given months to the number of Earth-days leading up to the Gregorian month.

date_from_days0
function

date_from_days(days)

Convert the given Earth-days into a Gregorian date in the common form: (year, month, day).

days_from_date0
function

days_from_date(date)

Convert a Gregorian date in the common form, (year, month, day), to the number of days leading up to the date.

context0
function

context(context)