1 /*
  2  * CopticRataDie.js - Represent an RD date in the Coptic calendar
  3  *
  4  * Copyright © 2015, 2018, 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 var JSUtils = require("./JSUtils.js");
 21 var CopticCal = require("./CopticCal.js");
 22 var EthiopicRataDie = require("./EthiopicRataDie.js");
 23 
 24 /**
 25  * @class
 26  * Construct a new Coptic RD date number object. The constructor parameters can
 27  * contain any of the following properties:
 28  *
 29  * <ul>
 30  * <li><i>unixtime<i> - sets the time of this instance according to the given
 31  * unix time. Unix time is the number of milliseconds since midnight on Jan 1, 1970.
 32  *
 33  * <li><i>julianday</i> - sets the time of this instance according to the given
 34  * Julian Day instance or the Julian Day given as a float
 35  *
 36  * <li><i>year</i> - any integer, including 0
 37  *
 38  * <li><i>month</i> - 1 to 13, where 1 means Thoout, 2 means Paope, etc., and 13 means Epagomene
 39  *
 40  * <li><i>day</i> - 1 to 30
 41  *
 42  * <li><i>hour</i> - 0 to 23. A formatter is used to display 12 hour clocks, but this representation
 43  * is always done with an unambiguous 24 hour representation
 44  *
 45  * <li><i>minute</i> - 0 to 59
 46  *
 47  * <li><i>second</i> - 0 to 59
 48  *
 49  * <li><i>millisecond</i> - 0 to 999
 50  *
 51  * <li><i>date</i> - use the given intrinsic Javascript date to initialize this one.
 52  * </ul>
 53  *
 54  * If the constructor is called with another Coptic date instance instead of
 55  * a parameter block, the other instance acts as a parameter block and its
 56  * settings are copied into the current instance.<p>
 57  *
 58  * If the constructor is called with no arguments at all or if none of the
 59  * properties listed above are present, then the RD is calculate based on
 60  * the current date at the time of instantiation. <p>
 61  *
 62  * If any of the properties from <i>year</i> through <i>millisecond</i> are not
 63  * specified in the params, it is assumed that they have the smallest possible
 64  * value in the range for the property (zero or one).<p>
 65  *
 66  *
 67  * @private
 68  * @constructor
 69  * @extends EthiopicRataDie
 70  * @param {Object=} params parameters that govern the settings and behaviour of this Coptic RD date
 71  */
 72 var CopticRataDie = function(params) {
 73     this.cal = params && params.cal || new CopticCal();
 74     this.rd = NaN;
 75     /**
 76      * The difference between the zero Julian day and the first Coptic date
 77      * of Friday, August 29, 284 CE Julian at 7:00am UTC.
 78      * @private
 79      * @type number
 80      */
 81     this.epoch = 1825028.5;
 82 
 83     var tmp = {};
 84     if (params) {
 85         JSUtils.shallowCopy(params, tmp);
 86     }
 87     tmp.cal = this.cal; // override the cal parameter that may be passed in
 88     EthiopicRataDie.call(this, tmp);
 89 };
 90 
 91 CopticRataDie.prototype = new EthiopicRataDie();
 92 CopticRataDie.prototype.parent = EthiopicRataDie;
 93 CopticRataDie.prototype.constructor = CopticRataDie;
 94 
 95 module.exports = CopticRataDie;
 96