Custom time period.

recur().on(2011, 2012, 2013).customPeriod('partOfDay');

@api public
328624
function (id) {
      var custom = later[id];
      if(!custom) throw new Error('Custom time period ' + id + ' not recognized!');

      add(id, custom.extent(new Date())[0], custom.extent(new Date())[1]);
      return this;
    }
379033
function initCalendar() {
        var day = new Date()
          , dayOfWeek = day.getDay()
          , $today = $("g:last > .day").eq(dayOfWeek).attr("title", getDateTime(day))
          , $prevDaysInWeek = $today.prevAll(".day")
          , $prevWeeks = $today.parent().prevAll("g")
          , enabledDays = 1
          ;

        // add today and disabled classes
        $today.attr("class", function (index, classNames) {
            return classNames + " today";
        });
        $today.nextAll(".day").attr("class", function (index, classNames) {
            return classNames + " disabled";
        });

        var i = 0;
        // each day
        $prevDaysInWeek.each(function () {

            // get the current day
            day = new Date();

            // set its date
            day.setDate(day.getDate() - (i++) - 1);

            // add title attribute
            $(this).attr("title", getDateTime(day));

            ++enabledDays;
        });

        // each week
        $prevWeeks.each(function () {

            // get the days of this week
            var $daysInWeek = $(this).children(".day");

            // each day
            for (var i = $daysInWeek.length - 1; i >= 0; i--) {

                // set the new date
                day.setDate(day.getDate() - 1);

                // today
                if (day.getFullYear() < new Date().getFullYear()) {
                    $($daysInWeek[i]).attr("class", function (index, classNames) {
                        return classNames + " today";
                    });
                }

                // add title attribute
                $daysInWeek.eq(i).attr("title", getDateTime(day));

                // disable day
                if (enabledDays >= 366) {
                    $daysInWeek[i].classList.add("disabled");
                }
                ++enabledDays;
            }
        });
    }
631431
public function getEndTime()
    {
        $count = \count($this->periods);

        return $count ? $this->periods[$count - 1]->getEndTime() : 0;
    }
1110040
public function getDefaultPeriod($defaultDate = null)
    {
        list($defaultDate, $defaultPeriod) = $this->getDefaultDateAndPeriod($defaultDate);

        return $defaultPeriod;
    }
374647
private static long periodEnd(long now, long period, QDate cal)
  {
    if (period < 0)
      return Long.MAX_VALUE;
    else if (period == 0)
      return now;

    if (period < 30 * DAY) {
      cal.setGMTTime(now);

      long localTime = cal.getLocalTime();

      localTime = localTime + (period - (localTime + 4 * DAY) % period);

      cal.setLocalTime(localTime);

      return cal.getGMTTime();
    }

    if (period % (30 * DAY) == 0) {
      int months = (int) (period / (30 * DAY));

      cal.setGMTTime(now);
      long year = cal.getYear();
      int month = cal.getMonth();

      cal.setLocalTime(0);
      
      cal.setDate(year, month + months, 1);

      return cal.getGMTTime();
    }

    if (period % (365 * DAY) == 0) {
      long years = (period / (365 * DAY));

      cal.setGMTTime(now);
      long year = cal.getYear();

      cal.setLocalTime(0);

      long newYear = year + (years - year % years);
      
      cal.setDate(newYear, 0, 1);

      return cal.getGMTTime();
    }

    cal.setGMTTime(now);

    long localTime = cal.getLocalTime();

    localTime = localTime + (period - (localTime + 4 * DAY) % period);

    cal.setLocalTime(localTime);

    return cal.getGMTTime();
  }
209099
public function getPeriodLabel()
	{
		$contexts = $this->contexts; // Protect the contexts
		try
		{
			// If there are only instant context and all the contexts have the same date...
			if ( ! $this->DurationContexts()->count() && count( $this->AllYears() ) == 1 )
			{
				$context = reset( $this->contexts );
				return $context['period']['endDate'];
			}
			else
			{
				$this->sortByStartDate();
				$startContext = reset( $this->contexts );
				$this->sortByEndDate();
				$endContext = end( $this->contexts );
				return "{$startContext['period']['startDate']} - {$endContext['period']['endDate']}";
			}
		}
		finally
		{
			$this->contexts = $contexts; // Restore
		}
	}
1110313
private function processPeriod($period)
    {
        $sub = null;

        if ($period == 'week' || $period == 'W') {
            $sub = \Zend_Date::WEEK;
        } elseif ($period == 'month' || $period == 'M') {
            $sub = \Zend_Date::MONTH;
        } elseif ($period == 'year') {
            $sub = \Zend_Date::YEAR;
        } elseif ($period == 'D') {
            $sub = \Zend_Date::DAY;
        }
        return $sub;
    }
465161
def __period_remaining(self):
        '''
        
        '''
        elapsed = self.clock() - self.last_reset
        return self.period - elapsed
355656
public function getPeriod($role = null) {
        $roles = $this->_get('roles');
        if (!isset($roles[$role])) {
            if ($role === null) {
                return null;
            }
            return $this->getPeriod();
        }
        return (int) $roles[$role]['period'];
    }
601647
public void setPeriod(ReadableInterval interval) {
        if (interval == null) {
            setPeriod(0L);
        } else {
            Chronology chrono = DateTimeUtils.getChronology(interval.getChronology());
            setPeriod(interval.getStartMillis(), interval.getEndMillis(), chrono);
        }
    }
815215
function(month, year, includeWeekends) {
    initialize(year, month);

    includeWeekends = includeWeekends || false;

    if (!month || !year) {
      throw Error('Month or year missing.');
    }

    var self = this;
    var holidays = [];

    if (!includeWeekends) {
      self.year.discardWeekends();
    }

    if (typeof self.year.holidays[month] !== 'undefined') {
      self.year.holidays[month].forEach(function(holiday) {
        holidays.push(holiday);
      });
    }

    return holidays;
  }
1366874
function startOfMonth() {
      var result = this.clone();
      result.day = 1;
      result.isDate = true;
      result.hour = 0;
      result.minute = 0;
      result.second = 0;
      return result;
    }
407561
function () {
        var i = 0;
        var len = 0;
        var actionData = null;

        if (!(this.constructor.periodicActions instanceof Array)) {
            return;
        }

        len = this.constructor.periodicActions.length;

        for (; i < len; i += 1) {
            actionData = this.constructor.periodicActions[i];
            this.startPeriodicAction(actionData.uuid, actionData.action, actionData.params, actionData.interval);
        }
    }
146188
function adjustDayOfMonth(self) {
        var fields = self.fields;
        var year = fields[YEAR];
        var month = fields[MONTH];
        var monthLen = getMonthLength(year, month);
        var dayOfMonth = fields[DAY_OF_MONTH];
        if (dayOfMonth > monthLen) {
            self.set(DAY_OF_MONTH, monthLen);
        }
    }
1252761
function(calendar) {
					while (m < calendar.minMonth) {
						y--;
						m += calendar.monthsInYear(y);
					}
					var yearMonths = calendar.monthsInYear(y);
					while (m > yearMonths - 1 + calendar.minMonth) {
						y++;
						m -= yearMonths;
						yearMonths = calendar.monthsInYear(y);
					}
				}
1332688
function (year) {
			var daysCount = 0;
			for (var i = 1; i <= 12; i++) {
				daysCount += this.daysInMonth(year, i);
			}
			return daysCount;
		}
15013
public function getSecond(): Period
    {
        $datepoint = $this->setTime(
            (int) $this->format('H'),
            (int) $this->format('i'),
            (int) $this->format('s')
        );

        return new Period($datepoint, $datepoint->add(new DateInterval('PT1S')));
    }