Estoy escribiendo un sitio donde el usuario podría ver el calendario con la traducción de fechas judío-civil, y también qué parasas shavua cae en qué Shabat.
Me gustaría saber cuál es la fórmula para calcular qué parashas shavua leemos en Shabat que se da por fecha judía. Obviamente, el cálculo difiere entre Israel y la Diáspora. Ambas variantes son necesarias.
Gracias.
Estoy seguro de que ya hay módulos escritos para este propósito (ya que, después de todo, existen muchos sitios y aplicaciones que muestran la parashá de la semana, y dudo que cada uno haya reinventado la rueda). Sin embargo, no conozco ninguno que esté disponible gratuitamente.
Una forma de hacerlo sería utilizar tablas de búsqueda para cada uno de los 14 tipos de años posibles. Pero si desea averiguar los parshiyos semanales a partir de los primeros principios, entonces los datos que necesita son los siguientes:
Comience con el hecho de que Parashat Bereishis se lee en el primer Shabat después del 22 de Tishrei (Shemini Atzeres).
Cada Shabat del año tiene que tener una parashá semanal, a menos que coincida con una festividad importante (Pesaj, Shavuot, Rosh Hashaná, Yom Kippur, Sucot o Shemini Atzeres).
Hay siete (en Israel, seis) pares de parshiyos que se pueden duplicar: Vayakhel-Pekudei, Tazria-Metzora, Acharei-Kedoshim, Behar-Bechukosai, Chukas-Balak (solo fuera de Israel), Matos-Mas'ei y Nitzavim-Vayelech.
Vezos Haberachah siempre estará en Simchas Torah (o en Israel, Shemini Atzeres), ya sea en Shabat o no.
Luego aplique las siguientes reglas, dadas en Shulján Aruj, Oraj Jaim 428:4 :
En un año regular, el Shabat antes de Pesaj siempre es Parashat Tzav. En un año bisiesto, es Metzora (o, cuando Rosh Hashanah era el jueves, Acharei Mos).
Para satisfacer esta regla, Vayakhel-Pekudei se combinará en la mayoría de los años regulares (excepto en el caso en que Rosh Hashaná fue el jueves y el año está "completo", porque entonces hay un Shabat adicional disponible entre Simjas Torá y Pesaj). Se separarán en todos los años bisiestos.
El Shabat antes de Shavuot es Parshas Bamidbar (excepto en los años bisiestos en los que Rosh Hashanah era el jueves, cuando es Naso).
Para satisfacer esta regla, en un año regular tendrá que haber tres conjuntos de parshiyos en el Libro de Vayikra que se combinen: Tazria-Metzora, Acharei-Kedoshim y Behar-Bechukosai. (La excepción es en Israel, en los años en que Pesaj comienza en Shabat, porque entonces el 22 de Nisán tiene una parashá semanal allí, ya que es un Shabat normal. En ese caso, en Israel, Behar y Bejukosai están separados). Los tres pares. de parshiyos se separarán en años bisiestos.
El Shabat después de Tish'a Be'Av es Parashat Va'eschanan.
Para satisfacer esta regla, en la mayoría de los años Matos-Mas'ei tendrá que combinarse. Las excepciones son los años bisiestos en los que Rosh Hashaná fue en jueves, y en Israel, también los años bisiestos en los que Pesaj comenzó en Shabat.
Además, fuera de Israel, en los años en que Shavuot es viernes y Shabat, habrá que combinar Chukas-Balak.
(Dependiendo de cuán universal desee que sea su sitio, es posible que también deba considerar las costumbres variantes. Creo que algunas comunidades yemenitas invierten las reglas de cuando se combinan Chukas-Balak vs. Matos-Mas'ei).
El Shabat antes de Rosh Hashaná es Nitzavim.
Para satisfacer esta regla (y aún tener todas las parshiyot completadas por Simchas Torah), en los años en que Rosh Hashanah es en jueves o Shabat, Nitzavim-Vayelech se combinan y se leen en Shabat antes de Rosh Hashanah.
Tuve que implementar esto en Javascript y tuve éxito. Así que aquí está la lógica de programación simple que utilicé:
Cree una matriz (o lista) de parashás. Obviamente, desea utilizar la transliteración o algo así.
Luego usó un conjunto complejo de declaraciones if para compensar según el tipo de año. Para calcular el tipo de año, use algo como esto:
function ytype(year){
var a,b,c
//ihly returns boolean if it's a leap year.
a=ihly(year)?1:0;
//get the first day of the hebrew year (1st of Tishrei)
var beg=gfxo(ffh(year,7,1));
var b=beg.getDay()+1;
//now based on what day of the week it is, set b
if (b==2){b=0;}
if (b==3){b=1;}
if (b==5){b=2;}
if (b==7){b=3;}
//get the first day of the next hebrew year
var end=gfxo(ffh(year+1,7,1));
//totdats=total day count of this year
totdays=(end.getTime()-beg.getTime())/24/60/60/1000;
//set c based on total days
if (totdays==353||totdays==383){c=0;}
if (totdays==354||totdays==384){c=1;}
if (totdays==355||totdays==385){c=2;}
//Now return: a=is it a leap year;
//b=day of week that year starts;
//c=total days type
return [a,b,c];
}
Luego configure todas sus sentencias if para cubrir todas las posibilidades. Hay 14 posibilidades en total (porque algunas variaciones nunca ocurren), y 2 de las posibilidades tienen la misma regla que otras. Eso deja 12 declaraciones if para cubrir. Según las declaraciones if, reorganice la matriz.
Comenzaré definiendo algunas funciones básicas para manipular la matriz:
function Psh(lp,add){
lp.unshift(add);
}
function Padd(lp,pos,add){
lp.splice(pos,0,add);
}
function Pcom(lp,pos){
var d='/';
lp[pos]=lp[pos]+d+lp[pos+1];
lp[pos+1]='TD';
}
function Pfin(lp){
for(i=0;i<lp.length;i++){
if(lp[i]=='TD'){
lp.splice(i,1);
i--;
}
}
}
Y ahora tenemos el enorme conjunto de sentencias if:
//toy is the type of year array we got above
function parshaParse(toy){
//PARSHAS is the original array of parshiyos (['Bereishis','Noach',....])
var lp=PARSHAS.slice(0);
var a=toy[0],b=toy[1],c=toy[2];
if (a==0&&b==0&&c==0){
Pcom(lp,21);
Pcom(lp,26);
Pcom(lp,28);
Pcom(lp,31);
Pcom(lp,41);
Pcom(lp,50);
Pfin(lp);
Padd(lp,25-1,'');//CHP
Psh(lp,'');//CHS
Psh(lp,'');//Haa
Psh(lp,'');//Vay
}
if(a==0&&b==0&&c==2||a==0&&b==1&&c==1){
Pcom(lp,21);
Pcom(lp,26);
Pcom(lp,28);
Pcom(lp,31);
Pcom(lp,38);
Pcom(lp,41);
Pcom(lp,50);
Pfin(lp);
Padd(lp,25-1,'');//CHP
Padd(lp,32-1,'');//Shav2
Psh(lp,'');//CHS
Psh(lp,'');//Haa
Psh(lp,'');//Vay
}
if(a==0&&b==2&&c==2){
Pcom(lp,26);
Pcom(lp,28);
Pcom(lp,31);
Pcom(lp,41);
Pfin(lp);
Padd(lp,26-1,'');//P7
Psh(lp,'');//CHS
Psh(lp,'');//YK
Psh(lp,'');//Haa
}
if(a==0&&b==2&&c==1){
Pcom(lp,21);
Pcom(lp,26);
Pcom(lp,28);
Pcom(lp,31);
Pcom(lp,41);
Pfin(lp);
Padd(lp,25-1,'');//p1
Padd(lp,26-1,'');//p8
Psh(lp,'');//CHS
Psh(lp,'');//YK
Psh(lp,'');//Haa
}
if(a==0&&b==3&&c==0){
Pcom(lp,21);
Pcom(lp,26);
Pcom(lp,28);
Pcom(lp,31);
Pcom(lp,41);
Pfin(lp);
Padd(lp,25-1,'');//p7
Psh(lp,'');//SHMA
Psh(lp,'');//Suk1
Psh(lp,'');//Haa
Psh(lp,'');//RH1
}
if(a==0&&b==3&&c==2){
Pcom(lp,21);
Pcom(lp,26);
Pcom(lp,28);
Pcom(lp,31);
Pcom(lp,41);
Pcom(lp,50);
Pfin(lp);
Padd(lp,25-1,'');//CHP
Psh(lp,'');//SHMA
Psh(lp,'');//Suk1
Psh(lp,'');//Haa
Psh(lp,'');//RH1
}
if(a==1&&b==0&&c==0){
Pcom(lp,38);
Pcom(lp,41);
Pcom(lp,50);
Pfin(lp);
Padd(lp,29-1,'');//CHP
Padd(lp,36-1,'');//Shav2
Psh(lp,'');//CHS
Psh(lp,'');//Haa
Psh(lp,'');//Vay
}
if(a==1&&b==0&&c==2||a==1&&b==1&&c==1){
Pcom(lp,41);
Pfin(lp);
Padd(lp,29-1,'');//P1
Padd(lp,30-1,'');//P8
Psh(lp,'');//CHS
Psh(lp,'');//Haa
Psh(lp,'');//Vay
}
if(a==1&&b==2&&c==0){
Padd(lp,30-1,'');//CHP
Psh(lp,'');//CHS
Psh(lp,'');//YK
Psh(lp,'');//Haa
}
if(a==1&&b==2&&c==2){
Pcom(lp,50);
Pfin(lp);
Padd(lp,30-1,'');//CHP
Psh(lp,'');//CHS
Psh(lp,'');//YK
Psh(lp,'');//Haa
}
if(a==1&&b==3&&c==0){
Pcom(lp,41);
Pcom(lp,50);
Pfin(lp);
Padd(lp,29-1,'');//CHP
Psh(lp,'');//SHMA
Psh(lp,'');//S1
Psh(lp,'');//Haa
Psh(lp,'');//RH1
}
if(a==1&&b==3&&c==2){
Pcom(lp,38);
Pcom(lp,41);
Pcom(lp,50);
Pfin(lp);
Padd(lp,29-1,'');//CHP
Padd(lp,36-1,'');//Shav2
Psh(lp,'');//SHMA
Psh(lp,'');//S1
Psh(lp,'');//Haa
Psh(lp,'');//RH1
}
//return the new array of parshiyos that is good for out type of year
return lp;
}
No tengo tiempo para explicar qué significan muchas de las abreviaturas que usé. Pero esta función compleja definirá una matriz de parashá para un año dado en orden de semanas.
Finalmente, busque el próximo Shabat de la fecha de hoy, tome el desplazamiento de la fecha de Shabat del primer Shabat del año (es decir, el primer Shabat después del 1 Tishrei) y divida por 7, para obtener el número entero de semanas . Tome el elemento de la matriz que corresponde a ese número entero.
Viola: tienes la parashá.
PD Si quieres más código: ¡solo pídelo!
Y aquí hay un código adicional que se ocupa de las fechas hebreas: puedes preguntarme sobre las siglas en los comentarios. Recuerda, escribí este código hace un tiempo...
//also important for the general code:
function int(o){return parseInt(o);}
function ranger(x,y){
var a=new Array();
for (i=x; i < y; ++i){a.push(i);}
return a;
}
function nmod(x,y){
return ((x%y)+y)%y;
}
function amod(x,y){
//todo: might need a fix or 2
return y+nmod(x,(-y));
}
//some constants:
GREGORIANEPOCH=1;
HEBREWEPOCH=-1373427;
NISAN=1;
IYYAR=NISAN + 1;
SIVAN = NISAN + 2;
TAMMUZ = NISAN + 3;
AV = NISAN + 4;
ELUL = NISAN + 5;
TISHRI = NISAN + 6;
MARHESHVAN = NISAN+ 7;
KISLEV = NISAN + 8;
TEVET = NISAN + 9;
SHEVAT = NISAN + 10;
ADAR = NISAN + 11;
ADARI = NISAN + 11;
ADARII = NISAN + 12;
function dihy(year){return hny(year + 1) - hny(year);}
function ihly(year){return ((7*year + 1) % 19) < 7;}
function ilm(year){return dihy(year) in {355:1,385:1};}
function isk(year){return dihy(year) in {353:1, 383:1};}
function gyfx(date){
approx = Math.floor((date - GREGORIANEPOCH + 2) * 400 / 146097);
start = GREGORIANEPOCH + 365 * approx + Math.floor(approx/4) - Math.floor(approx/100) + Math.floor(approx/400);
if (date < start){return int(approx);}
else{return int(approx + 1);}
}
function ffg(year,month,day){
m = amod((month - 2), 12);
y = year + Math.floor((month + 9)/12);
return int(GREGORIANEPOCH - 1 - 306 + 365 *(y - 1) + Math.floor((y - 1)/4) - Math.floor((y - 1)/100) + Math.floor((y - 1)/400) + Math.floor((3*m - 1)/5) + 30*(m - 1) + day);
}
function gfx(date){
y = gyfx(GREGORIANEPOCH - 1 + date + 306);
priorDays = date - ffg(y - 1, 3, 1);
month = int(amod(Math.floor((5*priorDays + 155)/153) + 2, 12));
year = int(y - Math.floor((month + 9)/12));
day = int(date - ffg(year, month, 1) + 1);
return [year, month, day];
}
function gfxo(date){
var a=gfx(date);
return new Date(a[0],a[1]-1,a[2]);
}
function lmohy(year){
if (ihly(year)){return 13;}
else{return 12;}
}
function ldohm(year,month){
if ((month in {2:1, 4:1, 6:1, 10:1, 13:1})||(month == 12 && !(ihly(year)))||(month == 8 && !(ilm(year)))||(month == 9 && isk(year))){return 29;}
else{return 30;}
}
function hced(year){
monthsElapsed = int(Math.floor((235*year - 234)/19.0));
partsElapsed = 12084 + 13753*monthsElapsed;
day = 29 * monthsElapsed + int(Math.floor(partsElapsed/25920.0));
if ((3*(day + 1) % 7) < 3){return day + 1;}
else{return day;}
}
function hnyd(year){
ny0 = hced(year - 1);
ny1 = hced(year);
ny2 = hced(year + 1);
if ((ny2 - ny1) == 356){return 2;}
else if ((ny1 - ny0) == 382){return 1;}
else{return 0;}
}
function hny(year){return HEBREWEPOCH + hced(year) + hnyd(year);}
function ffh(year, month, day){
if (month < TISHRI){ms = ranger(TISHRI, lmohy(year) + 1).concat(ranger(NISAN, month));}
else{ms = ranger(TISHRI, month);}
yearly=year;
return hny(year) + day - 1 + sum(ms.map(function lmb(x){return ldohm(yearly,x);}))
}
gfxo
y ffh
sería genial. Gracias.ihly
y ilm
funciones isk
. También sería útil un ligero descifrado de los acrónimos.
CodyBugstein
Vaca Efectiva