Returns a list of holiday dates for a province and year.
771015
def stat_holidays(province='BC', year=2015):
    
    return holidays.Canada(state=province, years=year).keys()
1370704
def dates(self, desc=None):
        ''''''
        c = self.dateinverse
        for key in self.keys(desc=desc):
            yield c(key)
527130
public HolidayMap getHolidays (final int nYear, @Nullable final String... aArgs)
  {
    return _getHolidays (nYear, m_aConfiguration, aArgs);
  }
482156
def log_vacation_days():
    
    days_off = get_days_off(rc.read())
    pretty_days = map(lambda day: day.strftime('%a %b %d %Y'), days_off)
    for day in pretty_days:
        print(day)
166419
def list_calendar_events(self, all_events=None, context_codes=None, end_date=None, excludes=None, start_date=None, type=None, undated=None):
        
        path = {}
        data = {}
        params = {}

        # OPTIONAL - type
        """Defaults to "event""""
        if type is not None:
            self._validate_enum(type, ["event", "assignment"])
            params["type"] = type

        # OPTIONAL - start_date
        """Only return events since the start_date (inclusive).
        Defaults to today. The value should be formatted as: yyyy-mm-dd or ISO 8601 YYYY-MM-DDTHH:MM:SSZ."""
        if start_date is not None:
            params["start_date"] = start_date

        # OPTIONAL - end_date
        """Only return events before the end_date (inclusive).
        Defaults to start_date. The value should be formatted as: yyyy-mm-dd or ISO 8601 YYYY-MM-DDTHH:MM:SSZ.
        If end_date is the same as start_date, then only events on that day are
        returned."""
        if end_date is not None:
            params["end_date"] = end_date

        # OPTIONAL - undated
        """Defaults to false (dated events only).
        If true, only return undated events and ignore start_date and end_date."""
        if undated is not None:
            params["undated"] = undated

        # OPTIONAL - all_events
        """Defaults to false (uses start_date, end_date, and undated criteria).
        If true, all events are returned, ignoring start_date, end_date, and undated criteria."""
        if all_events is not None:
            params["all_events"] = all_events

        # OPTIONAL - context_codes
        """List of context codes of courses/groups/users whose events you want to see.
        If not specified, defaults to the current user (i.e personal calendar,
        no course/group events). Limited to 10 context codes, additional ones are
        ignored. The format of this field is the context type, followed by an
        underscore, followed by the context id. For example: course_42"""
        if context_codes is not None:
            params["context_codes"] = context_codes

        # OPTIONAL - excludes
        """Array of attributes to exclude. Possible values are "description", "child_events" and "assignment""""
        if excludes is not None:
            params["excludes"] = excludes

        self.logger.debug("GET /api/v1/calendar_events with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/calendar_events".format(**path), data=data, params=params, all_pages=True)
502272
private DateList getCandidates(final Calendar rootSeed, final Date date, final Value value) {
        DateList dates = new DateList(value);
        if (date instanceof DateTime) {
            if (((DateTime) date).isUtc()) {
                dates.setUtc(true);
            } else {
                dates.setTimeZone(((DateTime) date).getTimeZone());
            }
        }
        dates.add(date);
        if (transformers.get(BYMONTH) != null) {
            dates = transformers.get(BYMONTH).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYMONTH processing: " + dates);
            }
        }

        if (transformers.get(BYWEEKNO) != null) {
            dates = transformers.get(BYWEEKNO).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYWEEKNO processing: " + dates);
            }
        }

        if (transformers.get(BYYEARDAY) != null) {
            dates = transformers.get(BYYEARDAY).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYYEARDAY processing: " + dates);
            }
        }

        if (transformers.get(BYMONTHDAY) != null) {
            dates = transformers.get(BYMONTHDAY).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYMONTHDAY processing: " + dates);
            }
        } else if (frequency == Frequency.MONTHLY || (frequency == Frequency.YEARLY && yearDayList.isEmpty()
                && weekNoList.isEmpty() && dayList.isEmpty())) {

            NumberList implicitMonthDayList = new NumberList();
            implicitMonthDayList.add(rootSeed.get(Calendar.DAY_OF_MONTH));
            ByMonthDayRule implicitRule = new ByMonthDayRule(implicitMonthDayList, frequency, Optional.ofNullable(weekStartDay));
            dates = implicitRule.transform(dates);
        }

        if (transformers.get(BYDAY) != null) {
            dates = transformers.get(BYDAY).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYDAY processing: " + dates);
            }
        } else if (frequency == Frequency.WEEKLY || (frequency == Frequency.YEARLY && yearDayList.isEmpty()
                && !weekNoList.isEmpty() && monthDayList.isEmpty())) {

            ByDayRule implicitRule = new ByDayRule(new WeekDayList(WeekDay.getWeekDay(rootSeed)),
                    deriveFilterType(),  Optional.ofNullable(weekStartDay));
            dates = implicitRule.transform(dates);
        }

        if (transformers.get(BYHOUR) != null) {
            dates = transformers.get(BYHOUR).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYHOUR processing: " + dates);
            }
        }

        if (transformers.get(BYMINUTE) != null) {
            dates = transformers.get(BYMINUTE).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYMINUTE processing: " + dates);
            }
        }

        if (transformers.get(BYSECOND) != null) {
            dates = transformers.get(BYSECOND).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after BYSECOND processing: " + dates);
            }
        }

        if (transformers.get(BYSETPOS) != null) {
            dates = transformers.get(BYSETPOS).transform(dates);
            // debugging..
            if (log.isDebugEnabled()) {
                log.debug("Dates after SETPOS processing: " + dates);
            }
        }
        return dates;
    }
44637
function makeHoliday(date, info, observedInfo) {

  // always make the holiday.
  var holiday = {
    info: info,
    date: {
      month: date.getMonth(),
      day  : date.getDate()
    }
  }

  // if the holiday info's `bank` value has a function then
  // give it the date so it can evaluate the value.
  if ('function' === typeof info.bank) {
    info.bank = info.bank(date)
  }

  // without an observed holiday we return only the main holiday
  if (date.observed == null) {
    return holiday
  }

  // there's an observed date so return both holidays in an array.
  else {
    return [
      holiday, // main holiday
      {        // observed holiday
        info: observedInfo,
        date: {
          month: date.observed.getMonth(),
          day  : date.observed.getDate()
        }
      }
    ]
  }
}
628174
def _holiday_entry(self):
        """"""
        holidays_list = self.get_holidays_for_year()
        holidays_list = [
            holiday for holiday, holiday_hdate in holidays_list if
            holiday_hdate.hdate == self.hdate
        ]
        assert len(holidays_list) <= 1

        # If anything is left return it, otherwise return the "NULL" holiday
        return holidays_list[0] if holidays_list else htables.HOLIDAYS[0]
385098
public Date[] getDates()
   {
      int frequency = NumberHelper.getInt(m_frequency);
      if (frequency < 1)
      {
         frequency = 1;
      }

      Calendar calendar = DateHelper.popCalendar(m_startDate);
      List<Date> dates = new ArrayList<Date>();

      switch (m_recurrenceType)
      {
         case DAILY:
         {
            getDailyDates(calendar, frequency, dates);
            break;
         }

         case WEEKLY:
         {
            getWeeklyDates(calendar, frequency, dates);
            break;
         }

         case MONTHLY:
         {
            getMonthlyDates(calendar, frequency, dates);
            break;
         }

         case YEARLY:
         {
            getYearlyDates(calendar, dates);
            break;
         }
      }

      DateHelper.pushCalendar(calendar);
      
      return dates.toArray(new Date[dates.size()]);
   }
529870
def thanksgiving(year, country='usa'):
    ''''''
    if country == 'usa':
        if year in [1940, 1941]:
            return nth_day_of_month(3, THU, NOV, year)
        elif year == 1939:
            return nth_day_of_month(4, THU, NOV, year)
        else:
            return nth_day_of_month(0, THU, NOV, year)

    if country == 'canada':
        return nth_day_of_month(2, MON, OCT, year)
1330435
def holidays_set(self, year=None):
        ""
        return set([day for day, label in self.holidays(year)])
1112472
protected function getHolidays($year)
    {
        $christmas = new DateTime($year.'-12-25', $this->timezone);
        $thanksgiving = new DateTime('fourth Thursday of November '.$year, $this->timezone);

        $holidays = array(
            new Holiday(clone $christmas, 'Christmas', $this->timezone),
            new Holiday(clone $thanksgiving, 'Thanksgiving Day', $this->timezone),
            new Holiday(new DateTime($year.'-1-1', $this->timezone), "New Year's Day", $this->timezone),
            new Holiday(new DateTime($year.'-7-4', $this->timezone), 'Independence Day', $this->timezone),
            new Holiday(new DateTime($year.'-11-11', $this->timezone), 'Veterans Day', $this->timezone),
            new Holiday(new DateTime('second Monday of October '.$year, $this->timezone), 'Columbus Day', $this->timezone),
            new Holiday(new DateTime('first Monday of September '.$year, $this->timezone), 'Labor Day', $this->timezone),
            new Holiday(new DateTime('last Monday of May '.$year, $this->timezone), 'Memorial Day', $this->timezone),
            new Holiday(new DateTime('third Monday of February '.$year, $this->timezone), "President's Day", $this->timezone),
            new Holiday(new DateTime('third Monday of January '.$year, $this->timezone), 'Martin Luther King, Jr. Day', $this->timezone),
        );

        $holidays[] = new Holiday($christmas->modify('-1 day'), 'Christmas Eve', $this->timezone);
        $holidays[] = new Holiday($thanksgiving->modify('+1 day'), 'Thanksgiving Adam', $this->timezone);

        return $holidays;
    }
980322
def add_holiday(self, start_dt, holiday_name, end_dt = None, calendar_id = 'notices'):
        ''''''

        assert(calendar_id in self.configured_calendar_ids.keys())
        calendarId = self.configured_calendar_ids[calendar_id]

        # Note: end_date is one day ahead e.g. for the New Years' holiday Dec 31-Jan 1st, we specify the end_date as Jan 2nd. This is what the calendar expects.
        if not end_dt:
            end_dt = start_dt
        start_date = date(year=start_dt.year, month=start_dt.month, day=start_dt.day)#, tzinfo=self.timezone)
        end_date = date(year=end_dt.year, month=end_dt.month, day=end_dt.day) + timedelta(days = 1) #, tzinfo=self.timezone)
        start_time = datetime(year=start_dt.year, month=start_dt.month, day=start_dt.day, hour=0, minute=0, second=0, tzinfo=self.timezone) + timedelta(days = -1)
        end_time = datetime(year=end_dt.year, month=end_dt.month, day=end_dt.day, hour=23, minute=59, second=59, tzinfo=self.timezone) + timedelta(days = 2)

        # Do not add the quarter multiple times
        events = self.get_events((start_time + timedelta(days = -1)).isoformat(), (end_time + timedelta(days = 1)).isoformat(), ignore_cancelled = True)
        for event in events:
            if event.summary.find(holiday_name) != -1:
                return False

        event_body = {
            'summary' : holiday_name,
            'description' : holiday_name,
            'start' : {'date' : start_date.isoformat(), 'timeZone' : self.timezone_string},
            'end' : {'date' : end_date.isoformat(), 'timeZone' : self.timezone_string},
            'status' : 'confirmed',
            'extendedProperties' : {
                'shared' : {
                    'event_type' : 'Holiday'
                }
            }
        }
        if abs((end_date - start_date).days) > 7:
            raise Exception('The range of dates from {0} to {1} is greater than expected. Please check to make sure that the dates are correct.'.format(start_date, end_date))
        elif end_date < start_date:
            raise Exception('Error: The end date {1} occurs before the start date ({0}).'.format(start_date, end_date))

        created_event = self.service.events().insert(calendarId = self.configured_calendar_ids[calendar_id], body = event_body).execute()
        return True
584427
def monthdatescalendar(cls, year, month):
        
        weeks = []
        week = []
        for day in NepCal.itermonthdates(year, month):
            week.append(day)
            if len(week) == 7:
                weeks.append(week)
                week = []
        if len(week) > 0:
            weeks.append(week)
        return weeks
417781
def GetCalendarDatesFieldValuesTuples(self):
    """"""
    result = []
    for date_tuple in self.GenerateCalendarDatesFieldValuesTuples():
      result.append(date_tuple)
    result.sort()  # helps with __eq__
    return result
889148
public static HolidayCalendar<Calendar> toHolidayCalendarSet(final HolidayCalendar<Date> dates) {
        final Set<Calendar> calendars = new HashSet<>();
        for (final Date date : dates.getHolidays()) {
            calendars.add(getCal(date));
        }
        return new DefaultHolidayCalendar<>(calendars, getCal(dates.getEarlyBoundary()), getCal(dates.getLateBoundary()));
    }
844947
def dates(self):
        ''' '''
        dates = []
        d = self.date_a
        while d < self.date_b:
            dates.append(d)
            d += datetime.timedelta(1)

        return dates