Gregorian calendar functions and data.
operator
callib0
centuries_in_cycle
centuries_in_cycle = 4
years_in_century
years_in_century = 100
years_in_decade
years_in_decade = 10
centuries_in_millennium
centuries_in_millennium = 10
month_names0
month_names = (
"january",
"february",
"march",
"april",
"may",
"june",
"july",
"august",
"september",
"october",
"november",
"december",
)
months_in_year0
months_in_year = len(month_names)
month_abbreviations0
month_abbreviations = (
"jan", "feb", "mar",
"apr", "may", "jun",
"jul", "aug", "sep",
"oct", "nov", "dec",
)
month_name_to_number0
month_name_to_number = {
month_names[i] : i for i in range(len(month_names))
}
calendar_year0
calendar_year = (
31, 28, 31, 30,
31, 30, 31, 31,
30, 31, 30, 31
)
calendar_leap0
calendar_leap = (calendar_year[0], calendar_year[1] + 1) + calendar_year[2:] # Feb29
leap_cycle0
leap_cycle = (
('leap', 1, calendar_leap),
('years', 3, calendar_year)
)
cycle0
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
calendar = callib.aggregate(cycle)
resolve_by_months0
resolve_by_months(months)
resolve_by_days0
resolve_by_days(days)
months_in_cycle0
months_in_cycle = months_in_year * years_in_century * centuries_in_cycle
r0
r = resolve_by_months(months_in_cycle-1)
days_in_cycle0
days_in_cycle = r[1] + r[-1]
year_is_leap0
year_is_leap(y)
Given a gregorian calendar year, determine whether it is a leap year.
month_from_days0
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
days_from_month(months)
Convert the given months to the number of Earth-days leading up to the Gregorian month.
date_from_days0
date_from_days(days)
Convert the given Earth-days into a Gregorian date in the common form: (year, month, day).
days_from_date0
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
context(context)