+from datetime import datetime, timedelta
+import time
+import calendar
+
+class Ephemeris:
+
+ def __init__(self, start = time.strptime('19960101000000', '%Y%m%d%H%M%S'),
+ end = datetime.now(), features = []):
+ self._start = start
+ self._end = end
+ self._features = features
+
+ self._dated_features = {}
+
+
+
+ def update(self):
+ pass
+
+
+
+ @property
+ def dated_features(self):
+ if self._dated_features == {}:
+ date = self._start
+ while date <= self._end:
+ dict_hour = {}
+ Date = time.strptime(datetime.strftime(date, '%m/%d/%Y %H:%M:%S'), '%m/%d/%Y %H:%M:%S')
+ for feature in self._features:
+ if feature == 'hour':
+ dict_hour['hour'] = Date.tm_hour
+ elif feature == 'dayInWeek':
+ dict_hour['dayInWeek'] = Date.tm_wday
+ elif feature == 'dayInMonth':
+ dict_hour['dayInMonth'] = Date.tm_mday
+ elif feature == 'month':
+ dict_hour['month'] = Date.tm_mon
+ elif feature == 'year':
+ dict_hour['year'] = Date.tm_year
+ elif feature == 'dayInYear':
+ # Si c'est une année bissextile et qu'on est après le 29 février, on compte une journée
+ # dans l'année de moins, car on va supprimer les 29 févriers, de sorte que les 14 juillets,
+ # les 24 décembre... tombent toujours
+ if calendar.isleap(Date.tm_year) and Date >= time.strptime("29/02/"+str(Date.tm_year), "%d/%m/%Y"):
+ dict_hour['dayInYear'] = Date.tm_yday -1
+ else:
+ dict_hour['dayInYear'] = Date.tm_yday
+ elif feature == 'weekInYear':
+ dict_hour['weekInYear'] = date.isocalendar()[1]
+ self._dated_features[date] = dict_hour
+ date += timedelta(hours=1)
+ return self._dated_features
\ No newline at end of file