Merge pull request #1059 from barakplasma/hebrew_calendar

app update: Hebrew Calendar
pull/1357/head
Gordon Williams 2021-12-13 13:12:00 +00:00 committed by GitHub
commit ba78819410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 95 additions and 209 deletions

View File

@ -33,10 +33,11 @@
"id": "hebrew_calendar", "id": "hebrew_calendar",
"name": "Hebrew Calendar", "name": "Hebrew Calendar",
"shortName": "HebCal", "shortName": "HebCal",
"version": "0.03", "version": "0.04",
"description": "lists the date according to the hebrew calendar", "description": "lists the date according to the hebrew calendar",
"icon": "app.png", "icon": "app.png",
"tags": "", "allow_emulator": false,
"tags": "tool,locale",
"supports": [ "supports": [
"BANGLEJS", "BANGLEJS",
"BANGLEJS2" "BANGLEJS2"
@ -47,6 +48,10 @@
"name": "hebrew_calendar.app.js", "name": "hebrew_calendar.app.js",
"url": "app.js" "url": "app.js"
}, },
{
"name": "hebrewDate",
"url": "hebrewDate.js"
},
{ {
"name": "hebrew_calendar.img", "name": "hebrew_calendar.img",
"url": "app-icon.js", "url": "app-icon.js",

View File

@ -1,3 +1,4 @@
0.01: New App! 0.01: New App!
0.02: using TS and rollup to bundle 0.02: using TS and rollup to bundle
0.03: bug fixes and support bangle 1 0.03: bug fixes and support bangle 1
0.04: removing TS

View File

@ -1,5 +1,5 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2021 Michael Salaverry
Copyright (c) 2016-20 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net) Copyright (c) 2016-20 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -1,17 +1,26 @@
!function(){"use strict"; g.clear();
/*!
* This script was taked from this page and ported to Node.js by Ionic Bizu let now = new Date();
* http://www.shamash.org/help/javadate.shtml
* let today = require('hebrewDate').hebrewDate(now);
* This script was adapted from C sources written by
* Scott E. Lee, which contain the following copyright notice: var mainmenu = {
* "": {
* Copyright 1993-1995, Scott E. Lee, all rights reserved. "title": "Hebrew Date"
* Permission granted to use, copy, modify, distribute and sell so long as },
* the above copyright and this permission statement are retained in all greg: {
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK. // @ts-ignore
* value: require('locale').date(now, 1),
* Bill Hastings },
* RBI Software Systems date: {
* bhastings@rbi.com value: today.date,
*/var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};var i=new function(t,i,e,o,r,n,h,a,s,f,u,l,v,c){this[0]=t,this[1]=i,this[2]=e,this[3]=o,this[4]=r,this[5]=n,this[6]=h,this[7]=a,this[8]=s,this[9]=f,this[10]=u,this[11]=l,this[12]=v,this[13]=c}("Tishri","Heshvan","Kislev","Tevet","Shevat","AdarI","AdarII","Nisan","Iyyar","Sivan","Tammuz","Av","Elul"),e=new function(t,i,e,o,r,n,h,a,s,f,u,l,v,c,y,d,m,M,b){this[0]=t,this[1]=i,this[2]=e,this[3]=o,this[4]=r,this[5]=n,this[6]=h,this[7]=a,this[8]=s,this[9]=f,this[10]=u,this[11]=l,this[12]=v,this[13]=c,this[14]=y,this[15]=d,this[16]=m,this[17]=M,this[18]=b}(12,12,13,12,12,13,12,13,12,12,13,12,12,13,12,12,13,12,13);g.clear();let o=new Date,r=function(o){var r,n,h=0,a=0,s=0,f=0,u=0,l=0,v=0;function c(t){var i,o,r,n;for(f=Math.floor((t+310)/6940),r=void 0,n=void 0,r=31524,n=(r+=45971*f)>>16,n+=2744*f,o=Math.floor(n/25920),r=(n-=25920*o)<<16|65535&r,i=Math.floor(r/25920),l=o<<16|i,v=r-=25920*i;l<t-6940+310;)f++,v+=179876755,l+=Math.floor(v/25920),v%=25920;for(u=0;u<18&&!(l>t-74);u++)v+=765433*e[u],l+=Math.floor(v/25920),v%=25920}function y(t,i,e){var o=i,r=o%7;return(e>=19440||!(2==t||5==t||7==t||10==t||13==t||16==t||18==t)&&2==r&&e>=9924||(3==t||6==t||8==t||11==t||14==t||17==t||0==t)&&1==r&&e>=16789)&&(o++,7==++r&&(r=0)),3!=r&&5!=r&&0!=r||o++,o}var d=o;return"object"===(void 0===d?"undefined":t(d))&&(r=o.getMonth()+1,n=o.getDate(),d=o.getFullYear()),function(t){var i,o=0,r=0,n=t-347997;if(c(n),n>=(o=y(u,l,v))){if(s=19*f+u+1,n<o+59)return void(n<o+30?(h=1,a=n-o+1):(h=2,a=n-o-29));v+=765433*e[u],l+=Math.floor(v/25920),r=y((u+1)%19,l,v%=25920)}else{if(s=19*f+u,n>=o-177)return void(n>o-30?(h=13,a=n-o+30):n>o-60?(h=12,a=n-o+60):n>o-89?(h=11,a=n-o+89):n>o-119?(h=10,a=n-o+119):n>o-148?(h=9,a=n-o+148):(h=8,a=n-o+178));if(13==e[(s-1)%19]){if(h=7,(a=n-o+207)>0)return;if(h--,(a+=30)>0)return;h--,a+=30}else{if(h=6,(a=n-o+207)>0)return;h--,a+=30}if(a>0)return;if(h--,(a+=29)>0)return;r=o,c(l-365),o=y(u,l,v)}if(l=n-o-29,355==(i=r-o)||385==i){if(l<=30)return h=2,void(a=l);l-=30}else{if(l<=29)return h=2,void(a=l);l-=29}h=3,a=l}(function(t,i,e){var o=0,r=0,n=void 0;return o=t<0?t+4801:t+4800,i>2?r=i-3:(r=i+9,o--),n=Math.floor(146097*Math.floor(o/100)/4),n+=Math.floor(o%100*1461/4),n+=Math.floor((153*r+2)/5),n+=e-32045}(d,r,n)),{year:s,month:h,date:a,month_name:i[h-1]}}(o);var n={"":{title:"Hebrew Date"},cal:{value:require("locale").date(o,1),onchange:()=>{}},date:{value:r.date,onchange:()=>{}},month:{value:r.month_name,onchange:()=>{}},year:{value:r.year,onchange:()=>{}}};E.showMenu(n)}(); },
month: {
value: today.month_name,
},
year: {
value: today.year,
}
};
// @ts-ignore
E.showMenu(mainmenu);

View File

@ -1,6 +1,5 @@
/*! /*!
* This script was taked from this page and ported to Node.js by Ionic Bizu * This script was taked from this page http://www.shamash.org/help/javadate.shtml and ported to Node.js by Ionică Bizău in https://github.com/IonicaBizau/hebrew-date
* http://www.shamash.org/help/javadate.shtml
* *
* This script was adapted from C sources written by * This script was adapted from C sources written by
* Scott E. Lee, which contain the following copyright notice: * Scott E. Lee, which contain the following copyright notice:
@ -14,33 +13,11 @@
* RBI Software Systems * RBI Software Systems
* bhastings@rbi.com * bhastings@rbi.com
*/ */
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var GREG_SDN_OFFSET = 32045, DAYS_PER_5_MONTHS = 153, DAYS_PER_4_YEARS = 1461, DAYS_PER_400_YEARS = 146097;
var GREG_SDN_OFFSET = 32045, var HALAKIM_PER_HOUR = 1080, HALAKIM_PER_DAY = 25920, HALAKIM_PER_LUNAR_CYCLE = 29 * HALAKIM_PER_DAY + 13753, HALAKIM_PER_METONIC_CYCLE = HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7);
DAYS_PER_5_MONTHS = 153, var HEB_SDN_OFFSET = 347997, NEW_MOON_OF_CREATION = 31524, NOON = 18 * HALAKIM_PER_HOUR, AM3_11_20 = 9 * HALAKIM_PER_HOUR + 204, AM9_32_43 = 15 * HALAKIM_PER_HOUR + 589;
DAYS_PER_4_YEARS = 1461, var SUN = 0, MON = 1, TUES = 2, WED = 3, THUR = 4, FRI = 5, SAT = 6;
DAYS_PER_400_YEARS = 146097;
var HALAKIM_PER_HOUR = 1080,
HALAKIM_PER_DAY = 25920,
HALAKIM_PER_LUNAR_CYCLE = 29 * HALAKIM_PER_DAY + 13753,
HALAKIM_PER_METONIC_CYCLE = HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7);
var HEB_SDN_OFFSET = 347997,
NEW_MOON_OF_CREATION = 31524,
NOON = 18 * HALAKIM_PER_HOUR,
AM3_11_20 = 9 * HALAKIM_PER_HOUR + 204,
AM9_32_43 = 15 * HALAKIM_PER_HOUR + 589;
var SUN = 0,
MON = 1,
TUES = 2,
WED = 3,
THUR = 4,
FRI = 5,
SAT = 6;
function weekdayarr(d0, d1, d2, d3, d4, d5, d6) { function weekdayarr(d0, d1, d2, d3, d4, d5, d6) {
this[0] = d0; this[0] = d0;
this[1] = d1; this[1] = d1;
@ -50,7 +27,6 @@ function weekdayarr(d0, d1, d2, d3, d4, d5, d6) {
this[5] = d5; this[5] = d5;
this[6] = d6; this[6] = d6;
} }
function gregmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) { function gregmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
this[0] = m0; this[0] = m0;
this[1] = m1; this[1] = m1;
@ -65,8 +41,7 @@ function gregmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
this[10] = m10; this[10] = m10;
this[11] = m11; this[11] = m11;
} }
function hebrewmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) {
function hebrewmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13?: any) {
this[0] = m0; this[0] = m0;
this[1] = m1; this[1] = m1;
this[2] = m2; this[2] = m2;
@ -82,7 +57,6 @@ function hebrewmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m
this[12] = m12; this[12] = m12;
this[13] = m13; this[13] = m13;
} }
function monthsperyeararr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18) { function monthsperyeararr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16, m17, m18) {
this[0] = m0; this[0] = m0;
this[1] = m1; this[1] = m1;
@ -104,12 +78,7 @@ function monthsperyeararr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12,
this[17] = m17; this[17] = m17;
this[18] = m18; this[18] = m18;
} }
var gWeekday = new weekdayarr("Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"), gMonth = new gregmontharr("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"), hMonth = new hebrewmontharr("Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI", "AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av", "Elul"), mpy = new monthsperyeararr(12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13);
var gWeekday = new weekdayarr("Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur"),
gMonth = new gregmontharr("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"),
hMonth = new hebrewmontharr("Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI", "AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av", "Elul"),
mpy = new monthsperyeararr(12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13);
/** /**
* hebrewDate * hebrewDate
* Convert the Gregorian dates into Hebrew calendar dates. * Convert the Gregorian dates into Hebrew calendar dates.
@ -124,55 +93,36 @@ var gWeekday = new weekdayarr("Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "S
* - `month_name`: The Hebrew month name. * - `month_name`: The Hebrew month name.
* - `date`: The Hebrew date. * - `date`: The Hebrew date.
*/ */
export const hebrewDate = function (inputDateOrYear: Date) { function hebrewDate(inputDateOrYear) {
var inputMonth, inputDate; var inputMonth, inputDate;
var hebrewMonth = 0, hebrewDate = 0, hebrewYear = 0, metonicCycle = 0, metonicYear = 0, moladDay = 0, moladHalakim = 0;
var hebrewMonth = 0,
hebrewDate = 0,
hebrewYear = 0,
metonicCycle = 0,
metonicYear = 0,
moladDay = 0,
moladHalakim = 0;
function GregorianToSdn(inputYear, inputMonth, inputDay) { function GregorianToSdn(inputYear, inputMonth, inputDay) {
var year = 0, month = 0, sdn = void 0;
var year = 0,
month = 0,
sdn = void 0;
// Make year a positive number // Make year a positive number
if (inputYear < 0) { if (inputYear < 0) {
year = inputYear + 4801; year = inputYear + 4801;
} else { }
else {
year = inputYear + 4800; year = inputYear + 4800;
} }
// Adjust the start of the year // Adjust the start of the year
if (inputMonth > 2) { if (inputMonth > 2) {
month = inputMonth - 3; month = inputMonth - 3;
} else { }
else {
month = inputMonth + 9; month = inputMonth + 9;
year--; year--;
} }
sdn = Math.floor(Math.floor(year / 100) * DAYS_PER_400_YEARS / 4); sdn = Math.floor(Math.floor(year / 100) * DAYS_PER_400_YEARS / 4);
sdn += Math.floor(year % 100 * DAYS_PER_4_YEARS / 4); sdn += Math.floor(year % 100 * DAYS_PER_4_YEARS / 4);
sdn += Math.floor((month * DAYS_PER_5_MONTHS + 2) / 5); sdn += Math.floor((month * DAYS_PER_5_MONTHS + 2) / 5);
sdn += inputDay - GREG_SDN_OFFSET; sdn += inputDay - GREG_SDN_OFFSET;
return sdn; return sdn;
} }
function SdnToHebrew(sdn) { function SdnToHebrew(sdn) {
var tishri1 = 0, var tishri1 = 0, tishri1After = 0, yearLength = 0, inputDay = sdn - HEB_SDN_OFFSET;
tishri1After = 0,
yearLength = 0,
inputDay = sdn - HEB_SDN_OFFSET;
FindTishriMolad(inputDay); FindTishriMolad(inputDay);
tishri1 = Tishri1(metonicYear, moladDay, moladHalakim); tishri1 = Tishri1(metonicYear, moladDay, moladHalakim);
if (inputDay >= tishri1) { if (inputDay >= tishri1) {
// It found Tishri 1 at the start of the year. // It found Tishri 1 at the start of the year.
hebrewYear = metonicCycle * 19 + metonicYear + 1; hebrewYear = metonicCycle * 19 + metonicYear + 1;
@ -180,7 +130,8 @@ export const hebrewDate = function (inputDateOrYear: Date) {
if (inputDay < tishri1 + 30) { if (inputDay < tishri1 + 30) {
hebrewMonth = 1; hebrewMonth = 1;
hebrewDate = inputDay - tishri1 + 1; hebrewDate = inputDay - tishri1 + 1;
} else { }
else {
hebrewMonth = 2; hebrewMonth = 2;
hebrewDate = inputDay - tishri1 - 29; hebrewDate = inputDay - tishri1 - 29;
} }
@ -191,7 +142,8 @@ export const hebrewDate = function (inputDateOrYear: Date) {
moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY); moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY);
moladHalakim = moladHalakim % HALAKIM_PER_DAY; moladHalakim = moladHalakim % HALAKIM_PER_DAY;
tishri1After = Tishri1((metonicYear + 1) % 19, moladDay, moladHalakim); tishri1After = Tishri1((metonicYear + 1) % 19, moladDay, moladHalakim);
} else { }
else {
// It found Tishri 1 at the end of the year. // It found Tishri 1 at the end of the year.
hebrewYear = metonicCycle * 19 + metonicYear; hebrewYear = metonicCycle * 19 + metonicYear;
if (inputDay >= tishri1 - 177) { if (inputDay >= tishri1 - 177) {
@ -199,44 +151,56 @@ export const hebrewDate = function (inputDateOrYear: Date) {
if (inputDay > tishri1 - 30) { if (inputDay > tishri1 - 30) {
hebrewMonth = 13; hebrewMonth = 13;
hebrewDate = inputDay - tishri1 + 30; hebrewDate = inputDay - tishri1 + 30;
} else if (inputDay > tishri1 - 60) { }
else if (inputDay > tishri1 - 60) {
hebrewMonth = 12; hebrewMonth = 12;
hebrewDate = inputDay - tishri1 + 60; hebrewDate = inputDay - tishri1 + 60;
} else if (inputDay > tishri1 - 89) { }
else if (inputDay > tishri1 - 89) {
hebrewMonth = 11; hebrewMonth = 11;
hebrewDate = inputDay - tishri1 + 89; hebrewDate = inputDay - tishri1 + 89;
} else if (inputDay > tishri1 - 119) { }
else if (inputDay > tishri1 - 119) {
hebrewMonth = 10; hebrewMonth = 10;
hebrewDate = inputDay - tishri1 + 119; hebrewDate = inputDay - tishri1 + 119;
} else if (inputDay > tishri1 - 148) { }
else if (inputDay > tishri1 - 148) {
hebrewMonth = 9; hebrewMonth = 9;
hebrewDate = inputDay - tishri1 + 148; hebrewDate = inputDay - tishri1 + 148;
} else { }
else {
hebrewMonth = 8; hebrewMonth = 8;
hebrewDate = inputDay - tishri1 + 178; hebrewDate = inputDay - tishri1 + 178;
} }
return; return;
} else { }
else {
if (mpy[(hebrewYear - 1) % 19] == 13) { if (mpy[(hebrewYear - 1) % 19] == 13) {
hebrewMonth = 7; hebrewMonth = 7;
hebrewDate = inputDay - tishri1 + 207; hebrewDate = inputDay - tishri1 + 207;
if (hebrewDate > 0) return; if (hebrewDate > 0)
return;
hebrewMonth--; hebrewMonth--;
hebrewDate += 30; hebrewDate += 30;
if (hebrewDate > 0) return; if (hebrewDate > 0)
hebrewMonth--; return;
hebrewDate += 30;
} else {
hebrewMonth = 6;
hebrewDate = inputDay - tishri1 + 207;
if (hebrewDate > 0) return;
hebrewMonth--; hebrewMonth--;
hebrewDate += 30; hebrewDate += 30;
} }
if (hebrewDate > 0) return; else {
hebrewMonth = 6;
hebrewDate = inputDay - tishri1 + 207;
if (hebrewDate > 0)
return;
hebrewMonth--;
hebrewDate += 30;
}
if (hebrewDate > 0)
return;
hebrewMonth--; hebrewMonth--;
hebrewDate += 29; hebrewDate += 29;
if (hebrewDate > 0) return; if (hebrewDate > 0)
return;
// We need the length of the year to figure this out,so find Tishri 1 of this year. // We need the length of the year to figure this out,so find Tishri 1 of this year.
tishri1After = tishri1; tishri1After = tishri1;
FindTishriMolad(moladDay - 365); FindTishriMolad(moladDay - 365);
@ -253,7 +217,8 @@ export const hebrewDate = function (inputDateOrYear: Date) {
return; return;
} }
moladDay -= 30; moladDay -= 30;
} else { }
else {
// Heshvan has 29 days // Heshvan has 29 days
if (moladDay <= 29) { if (moladDay <= 29) {
hebrewMonth = 2; hebrewMonth = 2;
@ -266,7 +231,6 @@ export const hebrewDate = function (inputDateOrYear: Date) {
hebrewMonth = 3; hebrewMonth = 3;
hebrewDate = moladDay; hebrewDate = moladDay;
} }
function FindTishriMolad(inputDay) { function FindTishriMolad(inputDay) {
// Estimate the metonic cycle number. Note that this may be an under // Estimate the metonic cycle number. Note that this may be an under
// estimate because there are 6939.6896 days in a metonic cycle not // estimate because there are 6939.6896 days in a metonic cycle not
@ -287,18 +251,15 @@ export const hebrewDate = function (inputDateOrYear: Date) {
} }
// Find the molad of Tishri closest to this date. // Find the molad of Tishri closest to this date.
for (metonicYear = 0; metonicYear < 18; metonicYear++) { for (metonicYear = 0; metonicYear < 18; metonicYear++) {
if (moladDay > inputDay - 74) break; if (moladDay > inputDay - 74)
break;
moladHalakim += HALAKIM_PER_LUNAR_CYCLE * mpy[metonicYear]; moladHalakim += HALAKIM_PER_LUNAR_CYCLE * mpy[metonicYear];
moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY); moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY);
moladHalakim = moladHalakim % HALAKIM_PER_DAY; moladHalakim = moladHalakim % HALAKIM_PER_DAY;
} }
} }
function MoladOfMetonicCycle() { function MoladOfMetonicCycle() {
var r1 = void 0, var r1 = void 0, r2 = void 0, d1 = void 0, d2 = void 0;
r2 = void 0,
d1 = void 0,
d2 = void 0;
// Start with the time of the first molad after creation. // Start with the time of the first molad after creation.
r1 = NEW_MOON_OF_CREATION; r1 = NEW_MOON_OF_CREATION;
// Calculate gMetonicCycle * HALAKIM_PER_METONIC_CYCLE. The upper 32 // Calculate gMetonicCycle * HALAKIM_PER_METONIC_CYCLE. The upper 32
@ -317,42 +278,34 @@ export const hebrewDate = function (inputDateOrYear: Date) {
moladDay = d2 << 16 | d1; moladDay = d2 << 16 | d1;
moladHalakim = r1; moladHalakim = r1;
} }
function Tishri1(metonicYear, moladDay, moladHalakim) { function Tishri1(metonicYear, moladDay, moladHalakim) {
var tishri1 = moladDay, var tishri1 = moladDay, dow = tishri1 % 7, leapYear = metonicYear == 2 || metonicYear == 5 || metonicYear == 7 || metonicYear == 10 || metonicYear == 13 || metonicYear == 16 || metonicYear == 18, lastWasLeapYear = metonicYear == 3 || metonicYear == 6 || metonicYear == 8 || metonicYear == 11 || metonicYear == 14 || metonicYear == 17 || metonicYear == 0;
dow = tishri1 % 7,
leapYear = metonicYear == 2 || metonicYear == 5 || metonicYear == 7 || metonicYear == 10 || metonicYear == 13 || metonicYear == 16 || metonicYear == 18,
lastWasLeapYear = metonicYear == 3 || metonicYear == 6 || metonicYear == 8 || metonicYear == 11 || metonicYear == 14 || metonicYear == 17 || metonicYear == 0;
// Apply rules 2,3 and 4 // Apply rules 2,3 and 4
if (moladHalakim >= NOON || !leapYear && dow == TUES && moladHalakim >= AM3_11_20 || lastWasLeapYear && dow == MON && moladHalakim >= AM9_32_43) { if (moladHalakim >= NOON || !leapYear && dow == TUES && moladHalakim >= AM3_11_20 || lastWasLeapYear && dow == MON && moladHalakim >= AM9_32_43) {
tishri1++; tishri1++;
dow++; dow++;
if (dow == 7) dow = 0; if (dow == 7)
dow = 0;
} }
// Apply rule 1 after the others because it can cause an additional delay of one day. // Apply rule 1 after the others because it can cause an additional delay of one day.
if (dow == WED || dow == FRI || dow == SUN) { if (dow == WED || dow == FRI || dow == SUN) {
tishri1++; tishri1++;
} }
return tishri1; return tishri1;
} }
var inputYear = inputDateOrYear;
var inputYear: Date | number = inputDateOrYear;
if ((typeof inputYear === "undefined" ? "undefined" : _typeof(inputYear)) === "object") { if ((typeof inputYear === "undefined" ? "undefined" : _typeof(inputYear)) === "object") {
inputMonth = inputDateOrYear.getMonth() + 1; inputMonth = inputDateOrYear.getMonth() + 1;
inputDate = inputDateOrYear.getDate(); inputDate = inputDateOrYear.getDate();
inputYear = inputDateOrYear.getFullYear(); inputYear = inputDateOrYear.getFullYear();
} }
SdnToHebrew(GregorianToSdn(inputYear, inputMonth, inputDate)); SdnToHebrew(GregorianToSdn(inputYear, inputMonth, inputDate));
return { return {
year: hebrewYear, year: hebrewYear,
month: hebrewMonth, month: hebrewMonth,
date: hebrewDate, date: hebrewDate,
month_name: hMonth[hebrewMonth - 1] month_name: hMonth[hebrewMonth - 1]
}; };
}; }
exports.hebrewDate = hebrewDate;

View File

@ -1,23 +0,0 @@
{
"name": "hebrew_calendar",
"version": "0.0.3",
"description": "Bangle.js app for seeing hebrew calendar",
"main": "app.js",
"types": "app.d.ts",
"scripts": {
"build": "rollup -c"
},
"author": {
"name": "Michael Salaverry",
"url": "https://github.com/barakplasma"
},
"license": "MIT",
"devDependencies": {
"@rollup/plugin-typescript": "^4.1.1",
"rollup": "^2.10.2",
"rollup-plugin-terser": "^5.3.0",
"terser": "^4.7.0",
"tslib": "^2.0.0",
"typescript": "^3.9.2"
}
}

View File

@ -1,15 +0,0 @@
import typescript from '@rollup/plugin-typescript';
import { terser } from 'rollup-plugin-terser';
export default {
input: './src/app.ts',
output: {
dir: '.',
format: 'iife',
name: 'hebrew_calendar'
},
plugins: [
typescript(),
terser(),
]
};

View File

@ -1,34 +0,0 @@
declare var Bangle: any;
declare var g: any;
declare var E: any;
declare var require: any;
g.clear();
let now = new Date();
import { hebrewDate } from "./hebrewDate";
let today = hebrewDate(now);
var mainmenu = {
"" : {
"title" : "Hebrew Date"
},
cal: {
value: require('locale').date(now,1),
onchange : () => {}
},
date: {
value : today.date,
onchange : () => {}
},
month: {
value : today.month_name,
onchange : () => {}
},
year: {
value : today.year,
onchange : () => {}
}
};
E.showMenu(mainmenu);

View File

@ -1,10 +0,0 @@
{
"compilerOptions": {
"module": "es2015",
"noImplicitAny": false,
"target": "es2015"
},
"include": [
"src"
]
}