/*
* Calendar.js - Represent a calendar object.
*
* Copyright © 2012-2015, 2023 JEDLSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @class
* Superclass for all calendar subclasses that contains shared
* functionality.
* This class is never instantiated on its own. Instead,
* you should use the {@link CalendarFactory} function to manufacture a new
* instance of a subclass of Calendar.
*
* @protected
* @constructor
*/
var Calendar = function() {
};
/* place for the subclasses to put their constructors so that the factory method
* can find them. Do this to add your calendar after it's defined:
* Calendar._constructors["mytype"] = Calendar.MyTypeConstructor;
*/
Calendar._constructors = {};
Calendar.prototype = {
/**
* Return the type of this calendar.
*
* @return {string} the name of the type of this calendar
*/
getType: function() {
throw "Cannot call methods of abstract class Calendar";
},
/**
* Return the number of months in the given year. The number of months in a year varies
* for some luni-solar calendars because in some years, an extra month is needed to extend the
* days in a year to an entire solar year. The month is represented as a 1-based number
* where 1=first month, 2=second month, etc.
*
* @param {number} year a year for which the number of months is sought
* @return {number} The number of months in the given year
*/
getNumMonths: function(year) {
throw "Cannot call methods of abstract class Calendar";
},
/**
* Return the number of days in a particular month in a particular year. This function
* can return a different number for a month depending on the year because of things
* like leap years.
*
* @param {number} month the month for which the length is sought
* @param {number} year the year within which that month can be found
* @return {number} the number of days within the given month in the given year
*/
getMonLength: function(month, year) {
throw "Cannot call methods of abstract class Calendar";
},
/**
* Return true if the given year is a leap year in this calendar.
* The year parameter may be given as a number.
*
* @param {number} year the year for which the leap year information is being sought
* @return {boolean} true if the given year is a leap year
*/
isLeapYear: function(year) {
throw "Cannot call methods of abstract class Calendar";
}
};
module.exports = Calendar;
Source