def gregorian_to_season(date): # Assuming date is a GregorianDate tuple year, month, day = date # Return the value season = get_season(date) season_start = gregorian.GregorianDate(season[0],*seasons[season[1]]) day = gregorian.difference(season_start,date) + 1 return SeasonDate(*season,day)
def season_to_gregorian(season): # Get the start of the season as a GregorianDate season_start = gregorian.GregorianDate(season.year,*seasons[season.season]) season_start_jdn = gregorian.to_jdn(season_start) # Add the day number to the date jdn = season_start_jdn + season.day - 1 # Return the value return gregorian.gregorian_from_jdn(jdn)
def __init__(self, jdn): self.jdn = jdn self.cylenian_date = cylenian.CylenianDate(self.jdn) self.gregorian_date = gregorian.GregorianDate(self.jdn) self.moon = moon.Moon(self.jdn)
import collections import gregorian # The leap eras in a 100-era timespan leap_eras = [4, 12, 21, 37, 46, 54, 71, 79, 87] # The names of the Cylenian months month_names = [ "Elsy'ondleð", "Nae Boryeð", "Seniðin", "Liðin Boryeð", "Emmiðiða", "Omilnin", "Karðondleð", "Seðaneðr", "Liliðin", "Liðin Maroo", "Fðileð", "Elseniðor", "Naeð Molið" ] # The Cylenian epoch as a Julian Date Number epoch = gregorian.to_jdn(gregorian.GregorianDate(-1944, 12, 21)) # Create a named tuple for Cylenian dates CylenianDate = collections.namedtuple("CylenianDate", ["era", "year", "month", "day"]) # Return whether an era is a leap era def is_leap_era(era): # Assert parameters if era <= 0: raise ValueError( "The era {:r} is not a valid era; only positive eras are supported" .format(era)) # Return the value return ((era - 1) % 100 + 1) in leap_eras
def gregorian_date(year, month, day): d = Date.from_gregorian(gregorian.GregorianDate(year, month, day)) return jsonify_date(d)