This is a convenience method to add a default derived
calendar to the project.

@return new ProjectCalendar instance
426667
public ProjectCalendar addDefaultDerivedCalendar()
   {
      ProjectCalendar calendar = add();

      calendar.setWorkingDay(Day.SUNDAY, DayType.DEFAULT);
      calendar.setWorkingDay(Day.MONDAY, DayType.DEFAULT);
      calendar.setWorkingDay(Day.TUESDAY, DayType.DEFAULT);
      calendar.setWorkingDay(Day.WEDNESDAY, DayType.DEFAULT);
      calendar.setWorkingDay(Day.THURSDAY, DayType.DEFAULT);
      calendar.setWorkingDay(Day.FRIDAY, DayType.DEFAULT);
      calendar.setWorkingDay(Day.SATURDAY, DayType.DEFAULT);

      return (calendar);
   }
387982
private void readCalendars(Storepoint phoenixProject)
   {
      Calendars calendars = phoenixProject.getCalendars();
      if (calendars != null)
      {
         for (Calendar calendar : calendars.getCalendar())
         {
            readCalendar(calendar);
         }

         ProjectCalendar defaultCalendar = m_projectFile.getCalendarByName(phoenixProject.getDefaultCalendar());
         if (defaultCalendar != null)
         {
            m_projectFile.getProjectProperties().setDefaultCalendarName(defaultCalendar.getName());
         }
      }
   }
540902
public function everyOddWeek()
    {
        $this->setScheduleMonth(self::ANY);
        $this->setScheduleWeek('odd');
        $this->setScheduleDayOfMonth(self::ANY);
        $this->setScheduleDayOfWeek(self::ANY);
        $this->setScheduleHour(0);
        $this->setScheduleMinute(0);

        return $this;
    }
566069
private Project.Calendars.Calendar writeCalendar(ProjectCalendar bc)
   {
      //
      // Create a calendar
      //
      Project.Calendars.Calendar calendar = m_factory.createProjectCalendarsCalendar();
      calendar.setUID(NumberHelper.getBigInteger(bc.getUniqueID()));
      calendar.setIsBaseCalendar(Boolean.valueOf(!bc.isDerived()));

      ProjectCalendar base = bc.getParent();
      // SF-329: null default required to keep Powerproject happy when importing MSPDI files
      calendar.setBaseCalendarUID(base == null ? NULL_CALENDAR_ID : NumberHelper.getBigInteger(base.getUniqueID()));
      calendar.setName(bc.getName());

      //
      // Create a list of normal days
      //
      Project.Calendars.Calendar.WeekDays days = m_factory.createProjectCalendarsCalendarWeekDays();
      Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime time;
      ProjectCalendarHours bch;

      List<Project.Calendars.Calendar.WeekDays.WeekDay> dayList = days.getWeekDay();

      for (int loop = 1; loop < 8; loop++)
      {
         DayType workingFlag = bc.getWorkingDay(Day.getInstance(loop));

         if (workingFlag != DayType.DEFAULT)
         {
            Project.Calendars.Calendar.WeekDays.WeekDay day = m_factory.createProjectCalendarsCalendarWeekDaysWeekDay();
            dayList.add(day);
            day.setDayType(BigInteger.valueOf(loop));
            day.setDayWorking(Boolean.valueOf(workingFlag == DayType.WORKING));

            if (workingFlag == DayType.WORKING)
            {
               Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes times = m_factory.createProjectCalendarsCalendarWeekDaysWeekDayWorkingTimes();
               day.setWorkingTimes(times);
               List<Project.Calendars.Calendar.WeekDays.WeekDay.WorkingTimes.WorkingTime> timesList = times.getWorkingTime();

               bch = bc.getCalendarHours(Day.getInstance(loop));
               if (bch != null)
               {
                  for (DateRange range : bch)
                  {
                     if (range != null)
                     {
                        time = m_factory.createProjectCalendarsCalendarWeekDaysWeekDayWorkingTimesWorkingTime();
                        timesList.add(time);

                        time.setFromTime(range.getStart());
                        time.setToTime(range.getEnd());
                     }
                  }
               }
            }
         }
      }

      //
      // Create a list of exceptions
      //
      // A quirk of MS Project is that these exceptions must be
      // in date order in the file, otherwise they are ignored
      //
      List<ProjectCalendarException> exceptions = new ArrayList<ProjectCalendarException>(bc.getCalendarExceptions());
      if (!exceptions.isEmpty())
      {
         Collections.sort(exceptions);
         writeExceptions(calendar, dayList, exceptions);
      }

      //
      // Do not add a weekdays tag to the calendar unless it
      // has valid entries.
      // Fixes SourceForge bug 1854747: MPXJ and MSP 2007 XML formats
      //
      if (!dayList.isEmpty())
      {
         calendar.setWeekDays(days);
      }

      writeWorkWeeks(calendar, bc);

      m_eventManager.fireCalendarWrittenEvent(bc);

      return (calendar);
   }
1292634
private ProjectCalendar deriveResourceCalendar(Integer parentCalendarID)
   {
      ProjectCalendar calendar = m_project.addDefaultDerivedCalendar();
      calendar.setUniqueID(Integer.valueOf(m_project.getProjectConfig().getNextCalendarUniqueID()));
      calendar.setParent(m_project.getCalendarByUniqueID(parentCalendarID));
      return calendar;
   }
1264899
public Project.Calendars.Calendar.WorkWeeks.WorkWeek.TimePeriod createProjectCalendarsCalendarWorkWeeksWorkWeekTimePeriod()
   {
      return new Project.Calendars.Calendar.WorkWeeks.WorkWeek.TimePeriod();
   }
1060645
private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar)
   {
      MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
      {
         @Override public String toString()
         {
            return calendar.getName();
         }
      };
      parentNode.add(calendarNode);

      MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
      calendarNode.add(daysFolder);

      for (Day day : Day.values())
      {
         addCalendarDay(daysFolder, calendar, day);
      }

      MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
      calendarNode.add(exceptionsFolder);

      for (ProjectCalendarException exception : calendar.getCalendarExceptions())
      {
         addCalendarException(exceptionsFolder, exception);
      }
   }
106994
protected function defineConsoleSchedule()
    {
        $this->app->singleton(Schedule::class, function ($app) {
            return new Schedule();
        });

        $schedule = $this->app->make(Schedule::class);

        $this->schedule($schedule);
    }
135514
private void setCalendarToLastRelativeDay(Calendar calendar)
   {
      calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
      int currentDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
      int requiredDayOfWeek = getDayOfWeek().getValue();
      int dayOfWeekOffset = 0;

      if (currentDayOfWeek > requiredDayOfWeek)
      {
         dayOfWeekOffset = requiredDayOfWeek - currentDayOfWeek;
      }
      else
      {
         if (currentDayOfWeek < requiredDayOfWeek)
         {
            dayOfWeekOffset = -7 + (requiredDayOfWeek - currentDayOfWeek);
         }
      }

      if (dayOfWeekOffset != 0)
      {
         calendar.add(Calendar.DAY_OF_YEAR, dayOfWeekOffset);
      }
   }
579937
private void writeCalendar(ProjectCalendar mpxj)
   {
      CalendarType xml = m_factory.createCalendarType();
      m_apibo.getCalendar().add(xml);
      String type = mpxj.getResource() == null ? "Global" : "Resource";

      xml.setBaseCalendarObjectId(getCalendarUniqueID(mpxj.getParent()));
      xml.setIsPersonal(mpxj.getResource() == null ? Boolean.FALSE : Boolean.TRUE);
      xml.setName(mpxj.getName());
      xml.setObjectId(mpxj.getUniqueID());
      xml.setType(type);

      StandardWorkWeek xmlStandardWorkWeek = m_factory.createCalendarTypeStandardWorkWeek();
      xml.setStandardWorkWeek(xmlStandardWorkWeek);

      for (Day day : EnumSet.allOf(Day.class))
      {
         StandardWorkHours xmlHours = m_factory.createCalendarTypeStandardWorkWeekStandardWorkHours();
         xmlStandardWorkWeek.getStandardWorkHours().add(xmlHours);
         xmlHours.setDayOfWeek(getDayName(day));

         for (DateRange range : mpxj.getHours(day))
         {
            WorkTimeType xmlWorkTime = m_factory.createWorkTimeType();
            xmlHours.getWorkTime().add(xmlWorkTime);

            xmlWorkTime.setStart(range.getStart());
            xmlWorkTime.setFinish(getEndTime(range.getEnd()));
         }
      }

      HolidayOrExceptions xmlExceptions = m_factory.createCalendarTypeHolidayOrExceptions();
      xml.setHolidayOrExceptions(xmlExceptions);

      if (!mpxj.getCalendarExceptions().isEmpty())
      {
         Calendar calendar = DateHelper.popCalendar();
         for (ProjectCalendarException mpxjException : mpxj.getCalendarExceptions())
         {
            calendar.setTime(mpxjException.getFromDate());
            while (calendar.getTimeInMillis() < mpxjException.getToDate().getTime())
            {
               HolidayOrException xmlException = m_factory.createCalendarTypeHolidayOrExceptionsHolidayOrException();
               xmlExceptions.getHolidayOrException().add(xmlException);

               xmlException.setDate(calendar.getTime());

               for (DateRange range : mpxjException)
               {
                  WorkTimeType xmlHours = m_factory.createWorkTimeType();
                  xmlException.getWorkTime().add(xmlHours);

                  xmlHours.setStart(range.getStart());

                  if (range.getEnd() != null)
                  {
                     xmlHours.setFinish(getEndTime(range.getEnd()));
                  }
               }
               calendar.add(Calendar.DAY_OF_YEAR, 1);
            }
         }
         DateHelper.pushCalendar(calendar);
      }
   }
459254
public Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes.WorkingTime createProjectCalendarsCalendarWorkWeeksWorkWeekWeekDaysWeekDayWorkingTimesWorkingTime()
   {
      return new Project.Calendars.Calendar.WorkWeeks.WorkWeek.WeekDays.WeekDay.WorkingTimes.WorkingTime();
   }
53503
public ProjectCalendar getEffectiveCalendar()
   {
      ProjectCalendar result = getCalendar();
      if (result == null)
      {
         result = getParentFile().getDefaultCalendar();
      }
      return result;
   }
127247
private void addCalendarDay(MpxjTreeNode parentNode, ProjectCalendar calendar, final Day day)
   {
      MpxjTreeNode dayNode = new MpxjTreeNode(day)
      {
         @Override public String toString()
         {
            return day.name();
         }
      };
      parentNode.add(dayNode);
      addHours(dayNode, calendar.getHours(day));
   }
638860
public final Calendar getCalendar() {
        Calendar calendar = calendarSelector.getCalendar();
        if (calendar == null) {
            calendar = entry.getCalendar();
        }

        return calendar;
    }
1121443
public ProjectCalendar getCalendar()
   {
      ProjectCalendar calendar = null;
      Resource resource = getResource();
      if (resource != null)
      {
         calendar = resource.getResourceCalendar();
      }

      Task task = getTask();
      if (calendar == null || task.getIgnoreResourceCalendar())
      {
         calendar = task.getEffectiveCalendar();
      }

      return calendar;
   }
881623
public function setCurrentDate()
    {
        $this->defaultValue = Carbon::now()->timezone($this->getTimezone())->format($this->getFormat());

        return $this;
    }
405376
public CalendarItem getCalendarItem(Rec fieldList)
    {
        return new CalendarRecordItem(this, -1, 0, 1, 2, -1)
        {
            public Object getIcon(int iIconType)
            {
                Record recProjectControl = getRecord(ProjectControl.PROJECT_CONTROL_FILE);
                ImageField field = null;
                String fieldSeq = (iIconType == CalendarConstants.START_ICON) ? ProjectControl.START_PARENT_ICON : ProjectControl.END_PARENT_ICON;
                if (this.isParentTask())
                    field = (ImageField)recProjectControl.getField(fieldSeq);
                fieldSeq = (iIconType == CalendarConstants.START_ICON) ? ProjectControl.START_ICON : ProjectControl.END_ICON;
                if ((field == null) || (field.isNull()))
                    field = (ImageField)recProjectControl.getField(fieldSeq);
                if (field.isNull())
                    return super.getIcon(iIconType);
                return field.getImage().getImage();
            }
            public int getHighlightColor()
            {
                Record recProjectControl = getRecord(ProjectControl.PROJECT_CONTROL_FILE);
                ColorField field = null;
                if (this.isParentTask())
                    field = (ColorField)recProjectControl.getField(ProjectControl.PARENT_TASK_COLOR);
                if ((field == null) || (field.isNull()))
                    field = (ColorField)recProjectControl.getField(ProjectControl.TASK_COLOR);
                if (field.isNull())
                    return super.getHighlightColor();
                return field.getColor();
            }
            public int getSelectColor()
            {
                Record recProjectControl = getRecord(ProjectControl.PROJECT_CONTROL_FILE);
                ColorField field = null;
                if (this.isParentTask())
                    field = (ColorField)recProjectControl.getField(ProjectControl.PARENT_TASK_SELECT_COLOR);
                if ((field == null) || (field.isNull()))
                    field = (ColorField)recProjectControl.getField(ProjectControl.TASK_SELECT_COLOR);
                if (field.isNull())
                    return super.getSelectColor();
                return field.getColor();
            }
            public boolean isParentTask()
            {
                return ((ProjectTask)getMainRecord()).isParentTask();
            }
        };
    }