code: private void writeCalendar(ProjectCalendar record) throws IOException
     {
        //
        // Test used to ensure that we don't write the default calendar used for the "Unassigned" resource
        //
        if (record.getParent() == null || record.getResource() != null)
        {
           m_buffer.setLength(0);
  
           if (record.getParent() == null)
           {
              m_buffer.append(MPXConstants.BASE_CALENDAR_RECORD_NUMBER);
              m_buffer.append(m_delimiter);
              if (record.getName() != null)
              {
                 m_buffer.append(record.getName());
              }
           }
           else
           {
              m_buffer.append(MPXConstants.RESOURCE_CALENDAR_RECORD_NUMBER);
              m_buffer.append(m_delimiter);
              m_buffer.append(record.getParent().getName());
           }
  
           for (DayType day : record.getDays())
           {
              if (day == null)
              {
                 day = DayType.DEFAULT;
              }
              m_buffer.append(m_delimiter);
              m_buffer.append(day.getValue());
           }
  
           m_buffer.append(MPXConstants.EOL);
           m_writer.write(m_buffer.toString());
  
           ProjectCalendarHours[] hours = record.getHours();
           for (int loop = 0; loop < hours.length; loop++)
           {
              if (hours[loop] != null)
              {
                 writeCalendarHours(record, hours[loop]);
              }
           }
  
           if (!record.getCalendarExceptions().isEmpty())
           {
              //
              // A quirk of MS Project is that these exceptions must be
              // in date order in the file, otherwise they are ignored.
              // The getCalendarExceptions method now guarantees that
              // the exceptions list is sorted when retrieved.
              //
              for (ProjectCalendarException ex : record.getCalendarExceptions())
              {
                 writeCalendarException(record, ex);
              }
           }
  
           m_eventManager.fireCalendarWrittenEvent(record);
        }
     }
docs: Write a calendar.
  
  @param record calendar instance
  @throws IOException