116 lines
3.2 KiB
JavaScript
116 lines
3.2 KiB
JavaScript
//! moment-holiday.js locale configuration
|
||
//! locale : pascha Related Holidays
|
||
//! author : Kodie Grantham : https://github.com/kodie
|
||
|
||
//(function() {
|
||
// var moment = (typeof require !== 'undefined' && require !== null) && !require.amd ? require('moment') : this.moment;
|
||
function init(moment) {
|
||
// moment.holidays.pascha = {
|
||
moment.modifyHolidays.add({
|
||
"Lent": {
|
||
date: 'pascha-46|pascha-3'
|
||
},
|
||
/*
|
||
"Holy Monday": {
|
||
date: 'pascha-6',
|
||
keywords_y: ['great', 'monday']
|
||
},
|
||
"Holy Tuesday": {
|
||
date: 'pascha-5',
|
||
keywords_y: ['great', 'tuesday']
|
||
},
|
||
"Holy Wednesday": {
|
||
date: 'pascha-4',
|
||
keywords_y: ['great', 'wednesday']
|
||
},
|
||
"Holy Thursday": {
|
||
date: 'pascha-3',
|
||
keywords_y: ['great', 'thursday']
|
||
},
|
||
"Holy Friday": {
|
||
date: 'pascha-2',
|
||
keywords_y: ['great', 'friday']
|
||
},
|
||
"Holy Saturday": {
|
||
date: 'pascha-1',
|
||
keywords_y: ['holy', 'saturday']
|
||
},
|
||
*/
|
||
"Pascha Sunday": {
|
||
date: 'pascha',
|
||
keywords_y: ['pascha'],
|
||
keywords: ['sunday']
|
||
},
|
||
"Bright Week": {
|
||
date: 'pascha+1|pascha+6'
|
||
},
|
||
"Pentecost Sunday": {
|
||
date: 'pascha+49',
|
||
keywords_y: ['pentecost'],
|
||
keywords: ['sunday']
|
||
},
|
||
//};
|
||
});
|
||
|
||
/*
|
||
const orthodoxDates = require("./pascha-dates.js");
|
||
|
||
var pascha = function(year) {
|
||
var date = orthodoxDates[year].split("-");
|
||
date[1] -= 1; // month needs to be zero index
|
||
return moment(date);
|
||
}
|
||
*/
|
||
|
||
/**
|
||
* Calculates Easter in the Gregorian/Western (Catholic and Protestant) calendar
|
||
* based on the algorithm by Oudin (1940) from http://www.tondering.dk/claus/cal/easter.php
|
||
* @returns {array} [int month, int day]
|
||
*/
|
||
var pascha = function(year) {
|
||
var f = Math.floor,
|
||
// Golden Number - 1
|
||
G = year % 19,
|
||
C = f(year / 100),
|
||
// related to Epact
|
||
H = (C - f(C / 4) - f((8 * C + 13)/25) + 19 * G + 15) % 30,
|
||
// number of days from 21 March to the Paschal full moon
|
||
I = H - f(H/28) * (1 - f(29/(H + 1)) * f((21-G)/11)),
|
||
// weekday for the Paschal full moon
|
||
J = (year + f(year / 4) + I + 2 - C + f(C / 4)) % 7,
|
||
// number of days from 21 March to the Sunday on or before the Paschal full moon
|
||
L = I - J,
|
||
month = 3 + f((L + 40)/44),
|
||
day = L + 28 - 31 * f(month / 4);
|
||
|
||
return moment([year, (month - 1),day]);
|
||
}
|
||
|
||
moment.modifyHolidays.extendParser(function(m, date){
|
||
if (~date.indexOf('pascha')) {
|
||
var dates = date.split('|');
|
||
var ds = [];
|
||
|
||
for (var i = 0; i < dates.length; i++) {
|
||
if (dates[i].substring(0, 6) === 'pascha') {
|
||
var e = pascha(m.year());
|
||
|
||
if (dates[i].charAt(6) === '-') { e.subtract(dates[i].substring(7), 'days'); }
|
||
if (dates[i].charAt(6) === '+') { e.add(dates[i].substring(7), 'days'); }
|
||
|
||
if (dates.length === 1) { return e; }
|
||
ds.push(e.format('M/D'));
|
||
} else {
|
||
ds.push(dates[i]);
|
||
}
|
||
}
|
||
|
||
if (ds.length) { return ds.join('|'); }
|
||
}
|
||
});
|
||
}
|
||
|
||
module.exports = init;
|
||
|
||
// if ((typeof module !== 'undefined' && module !== null ? module.exports : void 0) != null) { module.exports = moment; }
|
||
//}).call(this);
|