X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/predictops.git/blobdiff_plain/a2faba3f0797b7be72d0c8fa9cb9db67456136d6..90e69cb2125d4bae76a27b9c38defb4f70bf2ca6:/predictops/source/holidays.py diff --git a/predictops/source/holidays.py b/predictops/source/holidays.py index 1a536fe..6893db0 100644 --- a/predictops/source/holidays.py +++ b/predictops/source/holidays.py @@ -3,6 +3,7 @@ from datetime import datetime, timedelta from jours_feries_france.compute import JoursFeries from logging import getLogger from logging.config import fileConfig +from pathlib import Path from vacances_scolaires_france import SchoolHolidayDates import itertools @@ -90,17 +91,28 @@ class Holidays: bankHolidaysEve = tuple(u-timedelta(days=1) for u in bankHolidays) name = self._config['ZONE']['name'] date = self._start + Date = datetime.date(date) + tomorrow = date + timedelta(days=1) + Tomorrow = datetime.date(tomorrow) d = SchoolHolidayDates() + dict_hour = { + 'bankHolidays' : Date in bankHolidays, + 'bankHolidaysEve': Date in bankHolidaysEve, + 'holidays': d.is_holiday_for_zone(Date, self._get_academic_zone(name, date)), + 'holidaysEve': d.is_holiday_for_zone(Tomorrow, self._get_academic_zone(name, tomorrow)) + } while date <= self._end: - Date = datetime.date(date) - tomorrow = date + timedelta(days=1) - Tomorrow = datetime.date(tomorrow) - dict_hour = { - 'bankHolidays' : Date in bankHolidays, - 'bankHolidaysEve': Date in bankHolidaysEve, - 'holidays': d.is_holiday_for_zone(Date, self._get_academic_zone(name, date)), - 'holidaysEve': d.is_holiday_for_zone(Tomorrow, self._get_academic_zone(name, tomorrow)) - } self._dated_features[date] = dict_hour + current = date date += timedelta(hours=1) + if date.day != current.day: + Date = datetime.date(date) + tomorrow = date + timedelta(days=1) + Tomorrow = datetime.date(tomorrow) + dict_hour = { + 'bankHolidays' : Date in bankHolidays, + 'bankHolidaysEve': Date in bankHolidaysEve, + 'holidays': d.is_holiday_for_zone(Date, self._get_academic_zone(name, date)), + 'holidaysEve': d.is_holiday_for_zone(Tomorrow, self._get_academic_zone(name, tomorrow)) + } return self._dated_features \ No newline at end of file