1 /*
  2  * Calendar.js - Represent a calendar object.
  3  *
  4  * Copyright © 2012-2015, JEDLSoft
  5  *
  6  * Licensed under the Apache License, Version 2.0 (the "License");
  7  * you may not use this file except in compliance with the License.
  8  * You may obtain a copy of the License at
  9  *
 10  *     http://www.apache.org/licenses/LICENSE-2.0
 11  *
 12  * Unless required by applicable law or agreed to in writing, software
 13  * distributed under the License is distributed on an "AS IS" BASIS,
 14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  *
 16  * See the License for the specific language governing permissions and
 17  * limitations under the License.
 18  */
 19 
 20 /**
 21  * @class
 22  * Superclass for all calendar subclasses that contains shared
 23  * functionality. This class is never instantiated on its own. Instead,
 24  * you should use the {@link CalendarFactory} function to manufacture a new
 25  * instance of a subclass of Calendar.
 26  *
 27  * @private
 28  * @constructor
 29  */
 30 var Calendar = function() {
 31 };
 32 
 33 /* place for the subclasses to put their constructors so that the factory method
 34  * can find them. Do this to add your calendar after it's defined:
 35  * Calendar._constructors["mytype"] = Calendar.MyTypeConstructor;
 36  */
 37 Calendar._constructors = {};
 38 
 39 Calendar.prototype = {
 40     /**
 41      * Return the type of this calendar.
 42      *
 43      * @return {string} the name of the type of this calendar
 44      */
 45     getType: function() {
 46         throw "Cannot call methods of abstract class Calendar";
 47     },
 48 
 49     /**
 50      * Return the number of months in the given year. The number of months in a year varies
 51      * for some luni-solar calendars because in some years, an extra month is needed to extend the
 52      * days in a year to an entire solar year. The month is represented as a 1-based number
 53      * where 1=first month, 2=second month, etc.
 54      *
 55      * @param {number} year a year for which the number of months is sought
 56      * @return {number} The number of months in the given year
 57      */
 58     getNumMonths: function(year) {
 59         throw "Cannot call methods of abstract class Calendar";
 60     },
 61 
 62     /**
 63      * Return the number of days in a particular month in a particular year. This function
 64      * can return a different number for a month depending on the year because of things
 65      * like leap years.
 66      *
 67      * @param {number} month the month for which the length is sought
 68      * @param {number} year the year within which that month can be found
 69      * @return {number} the number of days within the given month in the given year
 70      */
 71     getMonLength: function(month, year) {
 72         throw "Cannot call methods of abstract class Calendar";
 73     },
 74 
 75     /**
 76      * Return true if the given year is a leap year in this calendar.
 77      * The year parameter may be given as a number.
 78      *
 79      * @param {number} year the year for which the leap year information is being sought
 80      * @return {boolean} true if the given year is a leap year
 81      */
 82     isLeapYear: function(year) {
 83         throw "Cannot call methods of abstract class Calendar";
 84     }
 85 };
 86 
 87 module.exports = Calendar;