# Path: flatlib/datetime.py
# class Datetime:
#     """ This class represents a specific moment in time given by
#     a date, a time and an UTC Offset. The UTC Offset is zero
#     by default (UTC+0) although an offset can be given.
#     
#     """
# 
#     # Calendar types
#     GREGORIAN = GREGORIAN
#     JULIAN = JULIAN
# 
#     def __init__(self, date, time=0, utcoffset=0, calendar=GREGORIAN):
#         # Prepare the variables
#         if isinstance(date, Date):
#             self.date = date
#         else:
#             self.date = Date(date, calendar)
# 
#         if isinstance(time, Time):
#             self.time = time
#         else:
#             self.time = Time(time)
# 
#         if isinstance(utcoffset, Time):
#             self.utcoffset = utcoffset
#         else:
#             self.utcoffset = Time(utcoffset)
# 
#         # Compute jd
#         self.jd = self.date.jdn + self.time.value / 24.0 - \
#                   self.utcoffset.value / 24.0 - 0.5
# 
#     @staticmethod
#     def fromJD(jd, utcoffset):
#         """ Builds a Datetime object given a jd and utc offset. """
#         if not isinstance(utcoffset, Time):
#             utcoffset = Time(utcoffset)
#         localJD = jd + utcoffset.value / 24.0
#         date = Date(round(localJD))
#         time = Time((localJD + 0.5 - date.jdn) * 24)
#         return Datetime(date, time, utcoffset)
# 
#     def getUTC(self):
#         """ Returns this Datetime localized for UTC. """
#         timeUTC = self.time.getUTC(self.utcoffset)
#         dateUTC = Date(round(self.jd))
#         return Datetime(dateUTC, timeUTC)
# 
#     def __str__(self):
#         return '<%s %s %s>' % (self.date.toString(),
#                                self.time.toString(),
#                                self.utcoffset.toString())
# 
# Path: flatlib/ephem/ephem.py
# def getObject(ID, date, pos):
# def getObjectList(IDs, date, pos):
# def getHouses(date, pos, hsys):
# def getHouseList(date, pos, hsys):
# def getAngleList(date, pos, hsys):
# def getFixedStar(ID, date):
# def getFixedStarList(IDs, date):
# def nextSolarReturn(date, lon):
# def prevSolarReturn(date, lon):
# def nextSunrise(date, pos):
# def nextSunset(date, pos):
# def lastSunrise(date, pos):
# def lastSunset(date, pos):
# def nextStation(ID, date):
# def prevSolarEclipse(date):
# def nextSolarEclipse(date):
# def prevLunarEclipse(date):
# def nextLunarEclipse(date):


from flatlib.datetime import Datetime
from flatlib.ephem import ephem
"""
    Author: João Ventura <flatangleweb@gmail.com>
    
    
    This recipe shows sample code for calculating the dates
    of the previous and next solar and lunar eclipses.

"""



# Build a Datetime object
date = Datetime('2016/10/11', '12:00', '+00:00')

# Get the date of the maximum phase of the next global lunar eclipse
lunar_eclipse = ephem.nextLunarEclipse(date)
print(lunar_eclipse)  # <2017/02/11 00:43:48 00:00:00>

# Get the date of the maximum phase of the next global solar eclipse

# Path: flatlib/datetime.py
# class Datetime:
#     """ This class represents a specific moment in time given by
#     a date, a time and an UTC Offset. The UTC Offset is zero
#     by default (UTC+0) although an offset can be given.
#     
#     """
# 
#     # Calendar types
#     GREGORIAN = GREGORIAN
#     JULIAN = JULIAN
# 
#     def __init__(self, date, time=0, utcoffset=0, calendar=GREGORIAN):
#         # Prepare the variables
#         if isinstance(date, Date):
#             self.date = date
#         else:
#             self.date = Date(date, calendar)
# 
#         if isinstance(time, Time):
#             self.time = time
#         else:
#             self.time = Time(time)
# 
#         if isinstance(utcoffset, Time):
#             self.utcoffset = utcoffset
#         else:
#             self.utcoffset = Time(utcoffset)
# 
#         # Compute jd
#         self.jd = self.date.jdn + self.time.value / 24.0 - \
#                   self.utcoffset.value / 24.0 - 0.5
# 
#     @staticmethod
#     def fromJD(jd, utcoffset):
#         """ Builds a Datetime object given a jd and utc offset. """
#         if not isinstance(utcoffset, Time):
#             utcoffset = Time(utcoffset)
#         localJD = jd + utcoffset.value / 24.0
#         date = Date(round(localJD))
#         time = Time((localJD + 0.5 - date.jdn) * 24)
#         return Datetime(date, time, utcoffset)
# 
#     def getUTC(self):
#         """ Returns this Datetime localized for UTC. """
#         timeUTC = self.time.getUTC(self.utcoffset)
#         dateUTC = Date(round(self.jd))
#         return Datetime(dateUTC, timeUTC)
# 
#     def __str__(self):
#         return '<%s %s %s>' % (self.date.toString(),
#                                self.time.toString(),
#                                self.utcoffset.toString())
# 
# Path: flatlib/ephem/ephem.py
# def getObject(ID, date, pos):
# def getObjectList(IDs, date, pos):
# def getHouses(date, pos, hsys):
# def getHouseList(date, pos, hsys):
# def getAngleList(date, pos, hsys):
# def getFixedStar(ID, date):
# def getFixedStarList(IDs, date):
# def nextSolarReturn(date, lon):
# def prevSolarReturn(date, lon):
# def nextSunrise(date, pos):
# def nextSunset(date, pos):
# def lastSunrise(date, pos):
# def lastSunset(date, pos):
# def nextStation(ID, date):
# def prevSolarEclipse(date):
# def nextSolarEclipse(date):
# def prevLunarEclipse(date):
# def nextLunarEclipse(date):


# Path: recipes/eclipses.py
from flatlib.datetime import Datetime
from flatlib.ephem import ephem

"""
    Author: João Ventura <flatangleweb@gmail.com>
    
    
    This recipe shows sample code for calculating the dates
    of the previous and next solar and lunar eclipses.

"""



# Build a Datetime object
date = Datetime('2016/10/11', '12:00', '+00:00')

# Get the date of the maximum phase of the next global lunar eclipse
lunar_eclipse = ephem.nextLunarEclipse(date)
print(lunar_eclipse)  # <2017/02/11 00:43:48 00:00:00>

# Get the date of the maximum phase of the next global solar eclipse

solar_eclipse = ephem.nextSolarEclipse(date)