+from configparser import ConfigParser
+from convertdate import islamic
+from datetime import datetime, timedelta
+from logging import getLogger
+from logging.config import fileConfig
+from pathlib import Path
+
+
+fileConfig((Path.cwd() / 'config') / 'logging.cfg')
+logger = getLogger()
+
+
+class Ramadan:
+
+ _start = None
+ _end = None
+
+ def __init__(self, config_file):
+
+ self._config = ConfigParser()
+ self._config.read(config_file)
+
+ # Collecting holidays features
+ self._features = [section for section in self._config
+ if self._config[section].getboolean('numerical')
+ or self._config[section].getboolean('categorical')]
+
+ self._dated_features = {}
+
+ @property
+ def start(self):
+ return self._start
+
+ @start.setter
+ def start(self, x):
+ self._start = x
+
+ @property
+ def end(self):
+ return self._end
+
+ @end.setter
+ def end(self, x):
+ self._end = x
+
+ @property
+ def dated_features(self):
+ if self._dated_features == {}:
+ logger.info("Adding Ramadan features")
+ date = self._start
+ while date <= self._end:
+ year, month, day = date.year, date.month, date.day
+ eve = datetime(year, month, day) - timedelta(days=1)
+ tomorrow = datetime(year, month, day) + timedelta(days=1)
+ Hegirian_month = islamic.from_gregorian(year, month, day)[1]
+ dict_hour = {
+ 'ramadanEve': False,
+ 'ramadan': False,
+ 'ramadanDayAfter': False
+ }
+ if Hegirian_month == 8 and\
+ islamic.from_gregorian(tomorrow.year, tomorrow.month, tomorrow.day)[1] == 9:
+ dict_hour['ramadanEve'] = True
+ elif Hegirian_month == 9:
+ dict_hour['ramadan'] = True
+ elif Hegirian_month == 10 and\
+ islamic.from_gregorian(eve.year, eve.month, eve.day)[1] == 9:
+ dict_hour['ramadanDayAfter'] = True
+ self._dated_features[date] = dict_hour
+ date += timedelta(hours=1)
+ return self._dated_features