Index: work_calendar/includes/entity.ui.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- work_calendar/includes/entity.ui.inc	(revision 28f71dbe8b88596f15af9840b68d05a0af771c97)
+++ work_calendar/includes/entity.ui.inc	(date 1534247770000)
@@ -47,6 +47,12 @@
     '#default_value' => $work_calendar->week_days,
     '#title' => t('Choose opening week days'),
   );
+  $form['holidays'] = array(
+	'#type' => 'textarea',
+	'#title' => t('Holidays'),
+	'#default_value' =>  $work_calendar->holidays,
+	'#description' =>  t("Enter your holiday list with format <b>mm/dd</b> or <b>dd-mm</b> Ex: <b>31-12</b>(EU) or <b>12/25</b>(US)<br/>21-11 23-11 (with space) that means from 21-11 to 23-11"),
+  );
   $form['actions'] = array('#type' => 'actions');
   $form['actions']['submit'] = array(
     '#type' => 'submit',
Index: work_calendar/includes/entity.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- work_calendar/includes/entity.inc	(revision 28f71dbe8b88596f15af9840b68d05a0af771c97)
+++ work_calendar/includes/entity.inc	(date 1534248038000)
@@ -28,11 +28,12 @@
   public $description;
   public $week = 0;
   public $week_days;
+  public $holidays;
 
   /**
    * Initialize object attributes and decode `week`.
    */
-  function __construct(array $values = array(), $entityType = 'work_calendar') {
+  public function __construct(array $values = array(), $entityType = 'work_calendar') {
     parent::__construct($values, $entityType);
     $this->week_days = array();
     foreach ($this->dayCodes() as $name => $code) {
@@ -48,14 +49,14 @@
    * Entities provided in code are automatically treated as locked, as well
    * as any fixed profile type.
    */
-  function isLocked() {
+  public function isLocked() {
     return isset($this->status) && empty($this->is_new) && (($this->status & ENTITY_IN_CODE) || ($this->status & ENTITY_FIXED));
   }
 
   /**
    * Encodes given week days into week byte.
    */
-  function updateWeek($week_days) {
+  public function updateWeek($week_days) {
     $codes = $this->dayCodes();
     $this->week = 0;
     foreach ($week_days as $name) {
@@ -111,7 +112,7 @@
    *
    * Internally it builds a rrule to do the job.
    */
-  private static function weekDaysDates($start, $end, $week_days) {
+  private static function weekDaysDates($start, $end, $week_days, $holidays = []) {
     // Transform $week_days to a rrule "byday" string. Example: SU,MO,TU,WE.
     // date_repeat api wants the byday array to start by the week day of $start.
     $byday = array();
@@ -133,8 +134,16 @@
     $dates = date_repeat_calc($rrule, (string)$start, (string)$end);
 
     // Strip hours from dates.
-    foreach ($dates as $key => $date) {
-      $dates[$key] = substr($date, 0, 10);
+    $reset = false;
+    foreach ($dates as $key => &$date) {
+      $date = substr($date, 0, 10);
+      if(!empty($holidays) && is_array($holidays) && in_array($date,$holidays)){
+      	unset($dates[$key]);
+      	$reset = true;
+      }
+    }
+    if($reset){
+	    $dates = array_values($dates);
     }
 
     // Special case. First day is always included in despite of the rrule.
@@ -150,16 +159,17 @@
   /**
    * Returns a list of opening days for the requested period.
    */
-  function getOpenDaysInPeriod($start, $end) {
+  public function getOpenDaysInPeriod($start, $end) {
     $week_days = $this->week_days;
-    $dates = self::weekDaysDates($start, $end, $week_days);
+    $holidays = self::holidays($this->holidays);
+    $dates = self::weekDaysDates($start, $end, $week_days, $holidays);
     return $dates;
   }
 
   /**
    * Returns a list of opening days for the requested year or month.
    */
-  function getOpenDays($year, $month = NULL) {
+  public function getOpenDays($year, $month = NULL) {
     list($start, $end) = self::periodDates($year, $month);
     return $this->getOpenDaysInPeriod($start, $end);
   }
@@ -167,16 +177,17 @@
   /**
    * Returns a list of closed days for the requested period.
    */
-  function getClosedDaysInPeriod($start, $end) {
+  public function getClosedDaysInPeriod($start, $end) {
     $week_days = array_diff(date_week_days_untranslated(), $this->week_days);
-    $dates = self::weekDaysDates($start, $end, $week_days);
+    $holidays = self::holidays($this->holidays);
+    $dates = self::weekDaysDates($start, $end, $week_days, $holidays);
     return $dates;
   }
 
   /**
    * Returns a list of closed days for the requested year or month.
    */
-  function getClosedDays($year, $month = NULL) {
+  public function getClosedDays($year, $month = NULL) {
     list($start, $end) = self::periodDates($year, $month);
     return $this->getClosedDaysInPeriod($start, $end);
   }
@@ -184,18 +195,88 @@
   /**
    * Returns boolean indicating wether the requested day the business is open.
    */
-  function isOpenDay($year, $month, $day) {
+  public function isOpenDay($year, $month, $day) {
+    if(self::isHoliday($year, $month, $day)){
+      return false;
+    };
     $date = new DateObject("$year-$month-$day 00:00:00");
     $week_day = self::weekDayName($date);
     return in_array($week_day, $this->week_days);
   }
 
   /**
-   * Returns boolean indicating wether the requested day the business is closed.
+   * Returns boolean indicating whether the requested day the business is closed.
    */
-  function isClosedDay($year, $month, $day) {
+  public function isClosedDay($year, $month, $day) {
+    if(self::isHoliday($year, $month, $day)){
+      return true;
+    };
     $date = new DateObject("$year-$month-$day 00:00:00");
     $week_day = self::weekDayName($date);
     return !in_array($week_day, $this->week_days);
   }
+
+  /*
+   * Convert holidays text to array DateTime current year
+   * Returns holidays array
+   */
+  public function holidays($holidays_text=''){
+  	$holidays = null;
+  	if(!empty($holidays_text)){
+  		$holidays = $holidays_text;
+    }
+    $convert_holiday_text = !empty($holidays)?explode(PHP_EOL, $holidays):null;
+  	if(!empty($convert_holiday_text)){
+	    $holidays = [];
+  		foreach ($convert_holiday_text as $holiday_date){
+		    $holiday_date = trim($holiday_date);
+		    $test_date_from = explode(' ', $holiday_date);
+		    if(!empty($test_date_from[1])){
+			    $holiday_date_from[] = $test_date_from;
+			    continue;
+		    }
+  			$test_date_us = explode('/', $holiday_date);
+  			if(!empty($test_date_us[1])){
+			    $holiday_date = implode('-', array_reverse($test_date_us));
+		    }
+		    $holiday_date .= '-'.date('Y');
+  			$datetime = strtotime($holiday_date);
+  			if(!empty($datetime)){
+			    $holidays[] = date('Y-m-d',$datetime);
+		    }
+	    }
+	    if(!empty($holiday_date_from)){
+  			foreach ($holiday_date_from as $date_from){
+			    foreach ($date_from as &$date_to){
+				    $test_date_us = explode('/', $date_to);
+				    if(!empty($test_date_us[1])){
+					    $date_to = implode('-', array_reverse($test_date_us));
+				    }
+				    $date_to .= '-'.date('Y');
+			    }
+			    $end_day = new DateTime($date_from[1]);
+			    $period = new DatePeriod(
+				    new DateTime($date_from[0]),
+				    new DateInterval('P1D'),
+				    $end_day->modify('+1 day')
+			    );
+			    foreach( $period as $date){
+				    $holidays[] = $date->format('Y-m-d');
+			    }
+		    }
+	    }
+    }
+    drupal_alter('work_calendar_holiday', $holidays);
+    return $holidays;
+  }
+
+  /**
+   * Returns boolean indicating whether the requested day the holiday.
+   */
+  public function isHoliday($year, $month, $day) {
+    $date = new DateObject("$year-$month-$day 00:00:00");
+    $holidays =  self::holidays($this->holidays);
+    if(empty($holidays)) return false;
+    return in_array($date->format("Y-m-d"),$holidays);
+  }
 }
Index: work_calendar/work_calendar.install
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- work_calendar/work_calendar.install	(revision 28f71dbe8b88596f15af9840b68d05a0af771c97)
+++ work_calendar/work_calendar.install	(date 1534247770000)
@@ -42,6 +42,12 @@
         'default' => 0,
         'description' => 'A bitwise representation of opening week days.',
       ),
+      'holidays' => array(
+        'type' => 'text',
+        'not null' => FALSE,
+        'size' => 'medium',
+        'description' => 'List of holidays.',
+      ),
     ) + entity_exportable_schema_fields(),
 
     'primary key' => array('id'),
@@ -59,3 +65,11 @@
 function work_calendar_uninstall() {
   variable_del('work_calendar_default');
 }
+
+/**
+ * Implements hook_update().
+ * Add new columns holidays to work_calendar.
+ */
+function work_calendar_update_7001() {
+  db_add_field('work_calendar', 'holidays', ['type' => 'text']);
+}
