jewish-date 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.3
4
+
5
+ - Added new method ```calcDaysInMonth (jewishYear: number,jewishMonth: JewishMonthType)``` will calculate the number of days in a Jewish month for a given Jewish year.
6
+
3
7
  ## 2.0.1
4
8
 
5
- - Add Support for ESM (ES modules)
9
+ - Added Support for ESM (ES modules)
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var z=Object.create;var d=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var L=(e,r)=>{for(var n in r)d(e,n,{get:r[n],enumerable:!0})},I=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of K(r))!q.call(e,s)&&s!==n&&d(e,s,{get:()=>r[s],enumerable:!(o=G(r,s))||o.enumerable});return e};var P=(e,r,n)=>(n=e!=null?z(R(e)):{},I(r||!e||!e.__esModule?d(n,"default",{value:e,enumerable:!0}):n,e)),_=e=>I(d({},"__esModule",{value:!0}),e);var Z={};L(Z,{JewishMonth:()=>t,convertNumberToHebrew:()=>y,formatJewishDate:()=>Q,formatJewishDateInHebrew:()=>X,getIndexByJewishMonth:()=>H,getJewishMonthByIndex:()=>j,getJewishMonthInHebrew:()=>S,getJewishMonthsInOrder:()=>E,isLeapYear:()=>J,toGregorianDate:()=>V,toHebrewJewishDate:()=>C,toJewishDate:()=>U});module.exports=_(Z);var t={None:"None",Tishri:"Tishri",Cheshvan:"Cheshvan",Kislev:"Kislev",Tevet:"Tevet",Shevat:"Shevat",Adar:"Adar",Nisan:"Nisan",Iyyar:"Iyyar",Sivan:"Sivan",Tammuz:"Tammuz",Av:"Av",Elul:"Elul",AdarI:"AdarI",AdarII:"AdarII"};var x=17214255e-1,W=347995.5;function c(e,r){return e-r*Math.floor(e/r)}function D(e){return e%4===0&&!(e%100===0&&e%400!==0)}function w(e,r,n){return x-1+365*(e-1)+Math.floor((e-1)/4)+-Math.floor((e-1)/100)+Math.floor((e-1)/400)+Math.floor((367*r-362)/12+(r<=2?0:D(e)?-1:-2)+n)}function g(e){let r=Math.floor(e-.5)+.5,n=r-x,o=Math.floor(n/146097),s=c(n,146097),a=Math.floor(s/36524),h=c(s,36524),b=Math.floor(h/1461),i=c(h,1461),M=Math.floor(i/365),u=o*400+a*100+b*4+M;a===4||M===4||u++;let $=r-w(u,1,1),O=r<w(u,3,1)?0:D(u)?1:2,v=Math.floor((($+O)*12+373)/367),Y=r-w(u,v,1)+1;return[u,v,Y]}function A(e){return c(e*7+1,19)<7}function k(e){return A(e)?13:12}function f(e){let r=Math.floor((235*e-234)/19),n=12084+13753*r,o=r*29+Math.floor(n/25920);return c(3*(o+1),7)<3&&o++,o}function F(e){let r=f(e-1),n=f(e);return f(e+1)-n===356?2:n-r===382?1:0}function T(e){return m(e+1,7,1)-m(e,7,1)}function l(e,r){return r===2||r===4||r===6||r===10||r===13||r===12&&!A(e)||r===8&&c(T(e),10)!==5||r===9&&c(T(e),10)===3?29:30}function m(e,r,n){let o,s=k(e),a=W+f(e)+F(e)+n+1;if(r<7){for(o=7;o<=s;o++)a+=l(e,o);for(o=1;o<r;o++)a+=l(e,o)}else for(o=7;o<r;o++)a+=l(e,o);return a}function N(e){let n,o,s=Math.floor(e)+.5,a=Math.floor((s-347995.5)*98496/35975351);n=a-1;for(let i=a;s>=m(i,7,1);i++)n++;let h=s<m(n,1,1)?7:1;o=h;for(let i=h;s>m(n,i,l(n,i));i++)o++;let b=s-m(n,o,1)+1;return[n,o,b]}var p=(e,r)=>e.toString().padStart(r,"0");var J=e=>{let r=e%19;return r===0||r===3||r===6||r===8||r===11||r===14||r===17},H=e=>({[t.None]:0,[t.Tishri]:7,[t.Cheshvan]:8,[t.Kislev]:9,[t.Tevet]:10,[t.Shevat]:11,[t.Adar]:12,[t.AdarI]:12,[t.AdarII]:13,[t.Nisan]:1,[t.Iyyar]:2,[t.Sivan]:3,[t.Tammuz]:4,[t.Av]:5,[t.Elul]:6})[e]||0,j=(e,r)=>{let o=[t.None,t.Nisan,t.Iyyar,t.Sivan,t.Tammuz,t.Av,t.Elul,t.Tishri,t.Cheshvan,t.Kislev,t.Tevet,t.Shevat,t.Adar,t.AdarII][e]||t.None;return o===t.Adar&&J(r)?t.AdarI:o},E=e=>{let r=[t.None,t.Tishri,t.Cheshvan,t.Kislev,t.Tevet,t.Shevat,t.AdarI,t.AdarII,t.Nisan,t.Iyyar,t.Sivan,t.Tammuz,t.Av,t.Elul];return J(e)?r:r.filter(n=>n!=="AdarII").map(n=>n==="AdarI"?"Adar":n)},Q=e=>`${e.day} ${e.monthName} ${e.year}`,U=e=>{let r=e.getFullYear(),n=e.getMonth()+1,o=e.getDate(),s=w(r,n,o),a=N(s),h=a[0],b=j(a[1],h),i=E(h).findIndex(u=>u===b);return{year:h,monthName:b,month:i,day:a[2]}},V=e=>{let r=H(e.monthName),n=m(e.year,r,e.day),o=g(n),s=`${p(o[0],4)}-${p(o[1],2)}-${p(o[2],2)}`,a=new Date(s);return a.getHours()>0&&a.setHours(0,0,0,0),a};var B=P(require("gematriya"));var S=e=>({[t.None]:"\u05DC\u05DC\u05D0",[t.Tishri]:"\u05EA\u05E9\u05E8\u05D9",[t.Cheshvan]:"\u05D7\u05E9\u05D5\u05DF",[t.Kislev]:"\u05DB\u05E1\u05DC\u05D5",[t.Tevet]:"\u05D8\u05D1\u05EA",[t.Shevat]:"\u05E9\u05D1\u05D8",[t.Adar]:"\u05D0\u05D3\u05E8",[t.AdarI]:"\u05D0\u05D3\u05E8 \u05D0",[t.AdarII]:"\u05D0\u05D3\u05E8 \u05D1",[t.Nisan]:"\u05E0\u05D9\u05E1\u05DF",[t.Iyyar]:"\u05D0\u05D9\u05D9\u05E8",[t.Sivan]:"\u05E1\u05D9\u05D5\u05DF",[t.Tammuz]:"\u05EA\u05DE\u05D5\u05D6",[t.Av]:"\u05D0\u05D1",[t.Elul]:"\u05D0\u05DC\u05D5\u05DC"})[e],y=(e,r=!0,n=!0)=>(0,B.default)(e,{geresh:r,punctuate:n}),C=e=>({day:y(e.day),monthName:S(e.monthName),year:y(e.year)}),X=e=>{let r=C(e);return`${r.day} ${r.monthName} ${r.year}`};
1
+ var z=Object.create;var f=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of K(t))!q.call(e,s)&&s!==n&&f(e,s,{get:()=>t[s],enumerable:!(o=G(t,s))||o.enumerable});return e};var P=(e,t,n)=>(n=e!=null?z(R(e)):{},v(t||!e||!e.__esModule?f(n,"default",{value:e,enumerable:!0}):n,e)),_=e=>v(f({},"__esModule",{value:!0}),e);var ee={};L(ee,{JewishMonth:()=>r,calcDaysInMonth:()=>X,convertNumberToHebrew:()=>I,formatJewishDate:()=>Q,formatJewishDateInHebrew:()=>Z,getIndexByJewishMonth:()=>J,getJewishMonthByIndex:()=>j,getJewishMonthInHebrew:()=>B,getJewishMonthsInOrder:()=>E,isLeapYear:()=>y,toGregorianDate:()=>V,toHebrewJewishDate:()=>C,toJewishDate:()=>U});module.exports=_(ee);var r={None:"None",Tishri:"Tishri",Cheshvan:"Cheshvan",Kislev:"Kislev",Tevet:"Tevet",Shevat:"Shevat",Adar:"Adar",Nisan:"Nisan",Iyyar:"Iyyar",Sivan:"Sivan",Tammuz:"Tammuz",Av:"Av",Elul:"Elul",AdarI:"AdarI",AdarII:"AdarII"};var D=17214255e-1,W=347995.5;function c(e,t){return e-t*Math.floor(e/t)}function g(e){return e%4===0&&!(e%100===0&&e%400!==0)}function d(e,t,n){return D-1+365*(e-1)+Math.floor((e-1)/4)+-Math.floor((e-1)/100)+Math.floor((e-1)/400)+Math.floor((367*t-362)/12+(t<=2?0:g(e)?-1:-2)+n)}function A(e){let t=Math.floor(e-.5)+.5,n=t-D,o=Math.floor(n/146097),s=c(n,146097),a=Math.floor(s/36524),h=c(s,36524),b=Math.floor(h/1461),i=c(h,1461),M=Math.floor(i/365),u=o*400+a*100+b*4+M;a===4||M===4||u++;let $=t-d(u,1,1),O=t<d(u,3,1)?0:g(u)?1:2,x=Math.floor((($+O)*12+373)/367),Y=t-d(u,x,1)+1;return[u,x,Y]}function N(e){return c(e*7+1,19)<7}function k(e){return N(e)?13:12}function l(e){let t=Math.floor((235*e-234)/19),n=12084+13753*t,o=t*29+Math.floor(n/25920);return c(3*(o+1),7)<3&&o++,o}function F(e){let t=l(e-1),n=l(e);return l(e+1)-n===356?2:n-t===382?1:0}function T(e){return m(e+1,7,1)-m(e,7,1)}function w(e,t){return t===2||t===4||t===6||t===10||t===13||t===12&&!N(e)||t===8&&c(T(e),10)!==5||t===9&&c(T(e),10)===3?29:30}function m(e,t,n){let o,s=k(e),a=W+l(e)+F(e)+n+1;if(t<7){for(o=7;o<=s;o++)a+=w(e,o);for(o=1;o<t;o++)a+=w(e,o)}else for(o=7;o<t;o++)a+=w(e,o);return a}function H(e){let n,o,s=Math.floor(e)+.5,a=Math.floor((s-347995.5)*98496/35975351);n=a-1;for(let i=a;s>=m(i,7,1);i++)n++;let h=s<m(n,1,1)?7:1;o=h;for(let i=h;s>m(n,i,w(n,i));i++)o++;let b=s-m(n,o,1)+1;return[n,o,b]}var p=(e,t)=>e.toString().padStart(t,"0");var y=e=>{let t=e%19;return t===0||t===3||t===6||t===8||t===11||t===14||t===17},J=e=>({[r.None]:0,[r.Tishri]:7,[r.Cheshvan]:8,[r.Kislev]:9,[r.Tevet]:10,[r.Shevat]:11,[r.Adar]:12,[r.AdarI]:12,[r.AdarII]:13,[r.Nisan]:1,[r.Iyyar]:2,[r.Sivan]:3,[r.Tammuz]:4,[r.Av]:5,[r.Elul]:6})[e]||0,j=(e,t)=>{let o=[r.None,r.Nisan,r.Iyyar,r.Sivan,r.Tammuz,r.Av,r.Elul,r.Tishri,r.Cheshvan,r.Kislev,r.Tevet,r.Shevat,r.Adar,r.AdarII][e]||r.None;return o===r.Adar&&y(t)?r.AdarI:o},E=e=>{let t=[r.None,r.Tishri,r.Cheshvan,r.Kislev,r.Tevet,r.Shevat,r.AdarI,r.AdarII,r.Nisan,r.Iyyar,r.Sivan,r.Tammuz,r.Av,r.Elul];return y(e)?t:t.filter(n=>n!=="AdarII").map(n=>n==="AdarI"?"Adar":n)},Q=e=>`${e.day} ${e.monthName} ${e.year}`,U=e=>{let t=e.getFullYear(),n=e.getMonth()+1,o=e.getDate(),s=d(t,n,o),a=H(s),h=a[0],b=j(a[1],h),i=E(h).findIndex(u=>u===b);return{year:h,monthName:b,month:i,day:a[2]}},V=e=>{let t=J(e.monthName),n=m(e.year,t,e.day),o=A(n),s=`${p(o[0],4)}-${p(o[1],2)}-${p(o[2],2)}`,a=new Date(s);return a.getHours()>0&&a.setHours(0,0,0,0),a},X=(e,t)=>{let n=J(t);return w(e,n)};var S=P(require("gematriya"));var B=e=>({[r.None]:"\u05DC\u05DC\u05D0",[r.Tishri]:"\u05EA\u05E9\u05E8\u05D9",[r.Cheshvan]:"\u05D7\u05E9\u05D5\u05DF",[r.Kislev]:"\u05DB\u05E1\u05DC\u05D5",[r.Tevet]:"\u05D8\u05D1\u05EA",[r.Shevat]:"\u05E9\u05D1\u05D8",[r.Adar]:"\u05D0\u05D3\u05E8",[r.AdarI]:"\u05D0\u05D3\u05E8 \u05D0",[r.AdarII]:"\u05D0\u05D3\u05E8 \u05D1",[r.Nisan]:"\u05E0\u05D9\u05E1\u05DF",[r.Iyyar]:"\u05D0\u05D9\u05D9\u05E8",[r.Sivan]:"\u05E1\u05D9\u05D5\u05DF",[r.Tammuz]:"\u05EA\u05DE\u05D5\u05D6",[r.Av]:"\u05D0\u05D1",[r.Elul]:"\u05D0\u05DC\u05D5\u05DC"})[e],I=(e,t=!0,n=!0)=>(0,S.default)(e,{geresh:t,punctuate:n}),C=e=>({day:I(e.day),monthName:B(e.monthName),year:I(e.year)}),Z=e=>{let t=C(e);return`${t.day} ${t.monthName} ${t.year}`};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/interfaces.ts", "../src/utils/dateUtils/dateConverterUtils.ts", "../src/utils/numberUtils/numberUtils.ts", "../src/jewishDate.ts", "../src/jewishDateHebrew.ts"],
4
- "sourcesContent": ["export * from \"./interfaces\";\nexport * from \"./jewishDate\";\nexport * from \"./jewishDateHebrew\";\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nexport const JewishMonth = {\n None: \"None\",\n\n Tishri: \"Tishri\",\n Cheshvan: \"Cheshvan\",\n Kislev: \"Kislev\",\n Tevet: \"Tevet\",\n Shevat: \"Shevat\",\n Adar: \"Adar\",\n Nisan: \"Nisan\",\n Iyyar: \"Iyyar\",\n Sivan: \"Sivan\",\n Tammuz: \"Tammuz\",\n Av: \"Av\",\n Elul: \"Elul\",\n\n AdarI: \"AdarI\",\n AdarII: \"AdarII\",\n} as const;\n\nexport type JewishMonthType = keyof typeof JewishMonth;\n\nexport interface BasicJewishDate {\n /**\n * day of month\n */\n day: number;\n\n /**\n * monthName\n */\n monthName: JewishMonthType;\n\n /**\n * month\n */\n year: number;\n}\n\nexport interface JewishDate extends BasicJewishDate {\n /**\n * month\n */\n month: number;\n}\n\nexport interface BasicJewishDateHebrew {\n /**\n * day of month\n */\n day: string;\n\n /**\n * monthName\n */\n monthName: string;\n\n /**\n * month\n */\n year: string;\n}\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nconst GREGORIAN_EPOCH = 1721425.5;\n\nconst HEBREW_EPOCH = 347995.5;\n\n/**\n * Computes the remainder of the division of `a` by `b`.\n * Unlike the built-in JavaScript `%` operator, this function handles negative numbers properly.\n * For example, `mod(-1, 5)` returns `4`, not `-1`.\n * @param {number} a - The number to compute the remainder of.\n * @param {number} b - The divisor.\n * @returns {number} - The remainder of `a` divided by `b`.\n */\nexport function mod(a: number, b: number) {\n return a - b * Math.floor(a / b);\n}\n\n/**\n * Determines if a given year is a leap year in the Gregorian calendar.\n * @param year The year to check.\n * @returns True if the year is a leap year, false otherwise.\n */\nfunction leapGregorian(year: number) {\n return year % 4 === 0 && !(year % 100 === 0 && year % 400 !== 0);\n}\n\n/**\n * Converts Gregorian date to Julian Day.\n * @param {number} year - The year in the Gregorian calendar.\n * @param {number} month - The month in the Gregorian calendar (January = 1).\n * @param {number} day - The day of the month in the Gregorian calendar.\n * @returns {number} The Julian Day corresponding to the Gregorian date.\n */\nexport function gregorianToJd(\n year: number,\n month: number,\n day: number,\n): number {\n return (\n GREGORIAN_EPOCH -\n 1 +\n 365 * (year - 1) +\n Math.floor((year - 1) / 4) +\n -Math.floor((year - 1) / 100) +\n Math.floor((year - 1) / 400) +\n Math.floor(\n (367 * month - 362) / 12 +\n (month <= 2 ? 0 : leapGregorian(year) ? -1 : -2) +\n day,\n )\n );\n}\n\n/**\n * Converts a Julian day number to Gregorian date.\n * @param {number} jd - The Julian day number to convert.\n * @returns {[number, number, number]} The Gregorian date as a tuple in the form of [year, month, day].\n */\nexport function jdToGregorian(jd: number): [number, number, number] {\n const wjd: number = Math.floor(jd - 0.5) + 0.5;\n const depoch: number = wjd - GREGORIAN_EPOCH;\n const quadricent: number = Math.floor(depoch / 146097);\n const dqc: number = mod(depoch, 146097);\n const cent: number = Math.floor(dqc / 36524);\n const dcent: number = mod(dqc, 36524);\n const quad: number = Math.floor(dcent / 1461);\n const dquad: number = mod(dcent, 1461);\n const yindex: number = Math.floor(dquad / 365);\n let year: number = quadricent * 400 + cent * 100 + quad * 4 + yindex;\n if (!(cent === 4 || yindex === 4)) {\n year++;\n }\n const yearday: number = wjd - gregorianToJd(year, 1, 1);\n const leapadj: number =\n wjd < gregorianToJd(year, 3, 1) ? 0 : leapGregorian(year) ? 1 : 2;\n const month: number = Math.floor(((yearday + leapadj) * 12 + 373) / 367);\n const day: number = wjd - gregorianToJd(year, month, 1) + 1;\n\n return [year, month, day];\n}\n\n/**\n * Determines if a Hebrew year is a leap year.\n * A leap year occurs 7 times in a 19 year cycle.\n * @param year - the Hebrew year to check\n * @returns true if the year is a leap year, false otherwise\n */\nfunction hebrewLeap(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n/**\n * Returns the number of months in a Hebrew year\n * @param {number} year - The Hebrew year\n * @returns {number} The number of months in the Hebrew year (12 or 13)\n */\nfunction hebrewYearMonths(year: number) {\n return hebrewLeap(year) ? 13 : 12;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year, taking into account the \"dechiya\" (postponement) rules\n * specified in the Mishnah, which state that the start of the year can't be Sunday, Wednesday, or Friday.\n * @param {number} year - The Hebrew year for which to calculate the delay.\n * @returns {number} The day of the molad (the moment of the astronomical new moon) for the specified Hebrew year.\n */\nfunction calculateHebrewYearStartDelay(year: number) {\n const months = Math.floor((235 * year - 234) / 19);\n const parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day++;\n }\n return day;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year due to the length of adjacent years,\n * taking into account the \"dechiya\" (postponement) rules specified in the Mishnah.\n * The rules state that if the length of the year that is next in the 19-year cycle\n * (i.e., in the year after the current year) is exactly 356 days, then the start of the current year\n * is delayed by two days. Similarly, if the length of the year that immediately precedes the current year\n * is 382 days, then the start of the current year is delayed by one day. Otherwise, there is no delay.\n *\n * @param year - The Hebrew year for which to calculate the delay.\n * @returns The delay in days of the start of the Hebrew year.\n */\nfunction calculateHebrewYearAdjacentDelay(year: number) {\n const last = calculateHebrewYearStartDelay(year - 1);\n const present = calculateHebrewYearStartDelay(year);\n const next = calculateHebrewYearStartDelay(year + 1);\n\n return next - present === 356 ? 2 : present - last === 382 ? 1 : 0;\n}\n\n/**\n * Calculates the number of days in a Hebrew year.\n * @param {number} year - The Hebrew year to calculate.\n * @returns {number} - The number of days in the Hebrew year.\n */\nfunction hebrewYearDays(year: number) {\n return hebrewToJd(year + 1, 7, 1) - hebrewToJd(year, 7, 1);\n}\n\n/**\n * Calculates the number of days in the specified month of the Hebrew year.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The month of the year, where Nisan is 1 and Adar II (in leap years) is 13.\n * @returns {number} - The number of days in the specified month.\n */\nfunction hebrewMonthDays(year: number, month: number) {\n if (\n month === 2 ||\n month === 4 ||\n month === 6 ||\n month === 10 ||\n month === 13\n ) {\n return 29;\n }\n\n if (month === 12 && !hebrewLeap(year)) {\n return 29;\n }\n\n if (month === 8 && !(mod(hebrewYearDays(year), 10) === 5)) {\n return 29;\n }\n\n if (month === 9 && mod(hebrewYearDays(year), 10) === 3) {\n return 29;\n }\n\n return 30;\n}\n\n/**\n * Converts a Hebrew date to the corresponding Julian day.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The Hebrew month (1-13).\n * @param {number} day - The day of the month.\n * @returns {number} The Julian day corresponding to the Hebrew date.\n */\nexport function hebrewToJd(year: number, month: number, day: number) {\n let mon: number;\n\n const months = hebrewYearMonths(year);\n let jd =\n HEBREW_EPOCH +\n calculateHebrewYearStartDelay(year) +\n calculateHebrewYearAdjacentDelay(year) +\n day +\n 1;\n\n if (month < 7) {\n for (mon = 7; mon <= months; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n for (mon = 1; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n } else {\n for (mon = 7; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n }\n\n return jd;\n}\n\n/**\n * Converts a Julian date to a Hebrew date.\n * @param jd - The Julian date to convert.\n * @returns The Hebrew date as a tuple in the form of [year, month, day].\n */\nexport function jdToHebrew(julianDate: number): [number, number, number] {\n const HEBREW_EPOCH = 347995.5;\n let year: number;\n let month: number;\n\n const jd = Math.floor(julianDate) + 0.5;\n const count: number = Math.floor(\n ((jd - HEBREW_EPOCH) * 98496.0) / 35975351.0,\n );\n year = count - 1;\n for (let i = count; jd >= hebrewToJd(i, 7, 1); i++) {\n year++;\n }\n const first: number = jd < hebrewToJd(year, 1, 1) ? 7 : 1;\n month = first;\n for (let i = first; jd > hebrewToJd(year, i, hebrewMonthDays(year, i)); i++) {\n month++;\n }\n const day = jd - hebrewToJd(year, month, 1) + 1;\n return [year, month, day];\n}\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\n/**\n * Pads a number with leading zeros until it reaches the desired length.\n * @param num - The number to pad.\n * @param len - The desired length of the padded number.\n * @returns A string representation of the padded number.\n */\nexport const toLength = (num: number, len: number) => {\n return num.toString().padStart(len, \"0\");\n};\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nimport {\n BasicJewishDate,\n JewishDate,\n BasicJewishDateHebrew,\n JewishMonth,\n JewishMonthType,\n} from \"./interfaces\";\nimport {\n gregorianToJd,\n hebrewToJd,\n jdToGregorian,\n jdToHebrew,\n} from \"./utils/dateUtils\";\nimport { toLength } from \"./utils/numberUtils\";\n\n/**\n * Checks if the given year is a leap year according to the Jewish calendar.\n * @param {number} year - The year to check.\n * @returns {boolean} True if the given year is a leap year according to the Jewish calendar, false otherwise.\n */\nexport const isLeapYear = (year: number): boolean => {\n const yearIndex = year % 19;\n return (\n yearIndex === 0 ||\n yearIndex === 3 ||\n yearIndex === 6 ||\n yearIndex === 8 ||\n yearIndex === 11 ||\n yearIndex === 14 ||\n yearIndex === 17\n );\n};\n\n/**\n * Returns the index of the given Jewish month in the Jewish calendar.\n * @param {JewishMonthType} jewishMonth - The Jewish month to get the index for.\n * @returns {number} The index of the given Jewish month in the Jewish calendar.\n */\nexport const getIndexByJewishMonth = (jewishMonth: JewishMonthType): number => {\n const jewishMonthsNamesDic = {\n [JewishMonth.None]: 0,\n\n [JewishMonth.Tishri]: 7,\n [JewishMonth.Cheshvan]: 8,\n [JewishMonth.Kislev]: 9,\n [JewishMonth.Tevet]: 10,\n [JewishMonth.Shevat]: 11,\n [JewishMonth.Adar]: 12,\n [JewishMonth.AdarI]: 12,\n [JewishMonth.AdarII]: 13,\n [JewishMonth.Nisan]: 1,\n [JewishMonth.Iyyar]: 2,\n [JewishMonth.Sivan]: 3,\n [JewishMonth.Tammuz]: 4,\n [JewishMonth.Av]: 5,\n [JewishMonth.Elul]: 6,\n };\n return jewishMonthsNamesDic[jewishMonth] || 0;\n};\n\n/**\n * Returns the Jewish month corresponding to the given index in the Jewish calendar of the given year.\n * @param {number} index - The index of the Jewish month to get (1-based).\n * @param {number} jewishYear - The year to get the Jewish month in.\n * @returns {JewishMonthType} The Jewish month corresponding to the given index in the Jewish calendar of the given year.\n */\nexport const getJewishMonthByIndex = (\n index: number,\n jewishYear: number,\n): JewishMonthType => {\n const jewishMonths: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.Adar,\n JewishMonth.AdarII,\n ];\n\n const month = jewishMonths[index] || JewishMonth.None;\n if (month === JewishMonth.Adar && isLeapYear(jewishYear)) {\n return JewishMonth.AdarI;\n }\n return month;\n};\n\n/**\n * Returns an array of the Jewish month names in the correct order for the given year.\n * @param {number} year - The Jewish year to get the months for.\n * @returns {string[]} An array of the Jewish month names in the correct order for the given year.\n * */\nexport const getJewishMonthsInOrder = (year: number): string[] => {\n const jewishMonthsInOrder: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.AdarI,\n JewishMonth.AdarII,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n ];\n if (isLeapYear(year)) {\n return jewishMonthsInOrder;\n } else {\n return jewishMonthsInOrder\n .filter((month) => month !== \"AdarII\")\n .map((month) => {\n if (month === \"AdarI\") {\n return \"Adar\";\n } else {\n return month;\n }\n });\n }\n};\n\n/**\n * Returns a string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n * @param {JewishDate} jewishDate - The Jewish date to format.\n * @returns {string} A string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n */\nexport const formatJewishDate = (jewishDate: JewishDate): string => {\n return `${jewishDate.day} ${jewishDate.monthName} ${jewishDate.year}`;\n};\n\n/**\n * Converts the given Gregorian date to a Jewish date.\n * @param {Date} date - The Gregorian date to convert.\n * @returns {JewishDate} The Jewish date corresponding to the given Gregorian date.\n */\nexport const toJewishDate = (date: Date): JewishDate => {\n const year = date.getFullYear();\n const month = date.getMonth() + 1;\n const day = date.getDate();\n // console.log({ year, month, day });\n const jd2 = gregorianToJd(year, month, day);\n\n const jewishDateArr = jdToHebrew(jd2);\n // console.log(jewishDateArr);\n\n const jewishYear = jewishDateArr[0];\n const jewishMonthName = getJewishMonthByIndex(jewishDateArr[1], jewishYear);\n // console.log({ jewishMonthName });\n const jewishMonth = getJewishMonthsInOrder(jewishYear).findIndex(\n (i) => i === jewishMonthName,\n );\n const JewishDate: JewishDate = {\n year: jewishYear,\n monthName: jewishMonthName,\n month: jewishMonth,\n day: jewishDateArr[2],\n };\n return JewishDate;\n};\n\n/**\n * Converts the given Jewish date to a Gregorian date.\n * @param {BasicJewishDate} jewishDate - The Jewish date to convert.\n * @returns {Date} The Gregorian date corresponding to the given Jewish date.\n * */\nexport const toGregorianDate = (jewishDate: BasicJewishDate): Date => {\n const jewishMonth = getIndexByJewishMonth(jewishDate.monthName);\n // console.log({ jewishMonth });\n const jd = hebrewToJd(jewishDate.year, jewishMonth, jewishDate.day);\n // console.log(jd);\n\n const gregDateArr = jdToGregorian(jd);\n // console.log(gregDateArr);\n const dateStr = `${toLength(gregDateArr[0], 4)}-${toLength(\n gregDateArr[1],\n 2,\n )}-${toLength(gregDateArr[2], 2)}`;\n // console.log(dateStr);\n\n const date = new Date(dateStr);\n if (date.getHours() > 0) {\n // fix issue in chrome that we chan't set hours in Date Constructor for year 0000\n date.setHours(0, 0, 0, 0);\n }\n return date;\n};\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nimport gematriya from \"gematriya\";\nimport {\n BasicJewishDate,\n BasicJewishDateHebrew,\n JewishMonth,\n JewishMonthType,\n} from \"./interfaces\";\n\n/**\n * Returns the name of a Jewish month in Hebrew, given its type.\n * @param {JewishMonthType} jewishMonth - The Jewish month type.\n * @returns {string} - The name of the Jewish month in Hebrew.\n */\nexport const getJewishMonthInHebrew = (\n jewishMonth: JewishMonthType,\n): string => {\n const jewishMonthsHebrewNamesDic = {\n [JewishMonth.None]: \"\u05DC\u05DC\u05D0\",\n\n [JewishMonth.Tishri]: \"\u05EA\u05E9\u05E8\u05D9\",\n [JewishMonth.Cheshvan]: \"\u05D7\u05E9\u05D5\u05DF\",\n [JewishMonth.Kislev]: \"\u05DB\u05E1\u05DC\u05D5\",\n [JewishMonth.Tevet]: \"\u05D8\u05D1\u05EA\",\n [JewishMonth.Shevat]: \"\u05E9\u05D1\u05D8\",\n [JewishMonth.Adar]: \"\u05D0\u05D3\u05E8\",\n [JewishMonth.AdarI]: \"\u05D0\u05D3\u05E8 \u05D0\",\n [JewishMonth.AdarII]: \"\u05D0\u05D3\u05E8 \u05D1\",\n [JewishMonth.Nisan]: \"\u05E0\u05D9\u05E1\u05DF\",\n [JewishMonth.Iyyar]: \"\u05D0\u05D9\u05D9\u05E8\",\n [JewishMonth.Sivan]: \"\u05E1\u05D9\u05D5\u05DF\",\n [JewishMonth.Tammuz]: \"\u05EA\u05DE\u05D5\u05D6\",\n [JewishMonth.Av]: \"\u05D0\u05D1\",\n [JewishMonth.Elul]: \"\u05D0\u05DC\u05D5\u05DC\",\n };\n return jewishMonthsHebrewNamesDic[jewishMonth];\n};\n\n/**\n * Converts a number to its Hebrew equivalent in gematria\n * @param num - The number to convert to Hebrew\n * @param addGeresh - Whether or not to add a geresh symbol (') to the end of the number\n * @param addPunctuate - Whether or not to add a punctuation mark (.) after the thousands digit\n * @returns The Hebrew equivalent of the given number\n */\nexport const convertNumberToHebrew = (\n num: number,\n addGeresh = true,\n addPunctuate = true,\n): string => {\n return gematriya(num, { geresh: addGeresh, punctuate: addPunctuate });\n};\n\n/**\n * Converts a basic Jewish date object to a Hebrew date object with Hebrew letters.\n * @param {BasicJewishDate} jewishDate - The basic Jewish date object to convert.\n * @returns {BasicJewishDateHebrew} The Hebrew date object with Hebrew letters.\n */\nexport const toHebrewJewishDate = (\n jewishDate: BasicJewishDate,\n): BasicJewishDateHebrew => {\n return {\n day: convertNumberToHebrew(jewishDate.day),\n monthName: getJewishMonthInHebrew(jewishDate.monthName),\n year: convertNumberToHebrew(jewishDate.year),\n };\n};\n\n/**\n * Formats a Jewish date object into a string representation in Hebrew.\n * @param {BasicJewishDate} jewishDate - The Jewish date object to format.\n * @returns {string} The Hebrew string representation of the Jewish date.\n */\nexport const formatJewishDateInHebrew = (\n jewishDate: BasicJewishDate,\n): string => {\n const jewishDateInHebrew = toHebrewJewishDate(jewishDate);\n return `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,CACjC,CAACC,EAAY,IAAI,EAAG,qBAEpB,CAACA,EAAY,MAAM,EAAG,2BACtB,CAACA,EAAY,QAAQ,EAAG,2BACxB,CAACA,EAAY,MAAM,EAAG,2BACtB,CAACA,EAAY,KAAK,EAAG,qBACrB,CAACA,EAAY,MAAM,EAAG,qBACtB,CAACA,EAAY,IAAI,EAAG,qBACpB,CAACA,EAAY,KAAK,EAAG,4BACrB,CAACA,EAAY,MAAM,EAAG,4BACtB,CAACA,EAAY,KAAK,EAAG,2BACrB,CAACA,EAAY,KAAK,EAAG,2BACrB,CAACA,EAAY,KAAK,EAAG,2BACrB,CAACA,EAAY,MAAM,EAAG,2BACtB,CAACA,EAAY,EAAE,EAAG,eAClB,CAACA,EAAY,IAAI,EAAG,0BACtB,GACkCD,CAAW,EAUlCE,EAAwB,CACnCC,EACAC,EAAY,GACZC,EAAe,QAER,EAAAC,SAAUH,EAAK,CAAE,OAAQC,EAAW,UAAWC,CAAa,CAAC,EAQzDE,EACXC,IAEO,CACL,IAAKN,EAAsBM,EAAW,GAAG,EACzC,UAAWT,EAAuBS,EAAW,SAAS,EACtD,KAAMN,EAAsBM,EAAW,IAAI,CAC7C,GAQWC,EACXD,GACW,CACX,IAAME,EAAqBH,EAAmBC,CAAU,EACxD,MAAO,GAAGE,EAAmB,GAAG,IAAIA,EAAmB,SAAS,IAAIA,EAAmB,IAAI,EAC7F",
6
- "names": ["src_exports", "__export", "JewishMonth", "convertNumberToHebrew", "formatJewishDate", "formatJewishDateInHebrew", "getIndexByJewishMonth", "getJewishMonthByIndex", "getJewishMonthInHebrew", "getJewishMonthsInOrder", "isLeapYear", "toGregorianDate", "toHebrewJewishDate", "toJewishDate", "__toCommonJS", "JewishMonth", "GREGORIAN_EPOCH", "HEBREW_EPOCH", "mod", "a", "b", "leapGregorian", "year", "gregorianToJd", "month", "day", "jdToGregorian", "jd", "wjd", "depoch", "quadricent", "dqc", "cent", "dcent", "quad", "dquad", "yindex", "yearday", "leapadj", "hebrewLeap", "hebrewYearMonths", "calculateHebrewYearStartDelay", "months", "parts", "calculateHebrewYearAdjacentDelay", "last", "present", "hebrewYearDays", "hebrewToJd", "hebrewMonthDays", "mon", "jdToHebrew", "julianDate", "count", "first", "toLength", "num", "len", "isLeapYear", "year", "yearIndex", "getIndexByJewishMonth", "jewishMonth", "JewishMonth", "getJewishMonthByIndex", "index", "jewishYear", "month", "getJewishMonthsInOrder", "jewishMonthsInOrder", "formatJewishDate", "jewishDate", "toJewishDate", "date", "day", "jd2", "gregorianToJd", "jewishDateArr", "jdToHebrew", "jewishMonthName", "i", "toGregorianDate", "jd", "hebrewToJd", "gregDateArr", "jdToGregorian", "dateStr", "toLength", "import_gematriya", "getJewishMonthInHebrew", "jewishMonth", "JewishMonth", "convertNumberToHebrew", "num", "addGeresh", "addPunctuate", "gematriya", "toHebrewJewishDate", "jewishDate", "formatJewishDateInHebrew", "jewishDateInHebrew"]
4
+ "sourcesContent": ["export * from \"./interfaces\";\nexport * from \"./jewishDate\";\nexport * from \"./jewishDateHebrew\";\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nexport const JewishMonth = {\n None: \"None\",\n\n Tishri: \"Tishri\",\n Cheshvan: \"Cheshvan\",\n Kislev: \"Kislev\",\n Tevet: \"Tevet\",\n Shevat: \"Shevat\",\n Adar: \"Adar\",\n Nisan: \"Nisan\",\n Iyyar: \"Iyyar\",\n Sivan: \"Sivan\",\n Tammuz: \"Tammuz\",\n Av: \"Av\",\n Elul: \"Elul\",\n\n AdarI: \"AdarI\",\n AdarII: \"AdarII\",\n} as const;\n\nexport type JewishMonthType = keyof typeof JewishMonth;\n\nexport interface BasicJewishDate {\n /**\n * day of month\n */\n day: number;\n\n /**\n * monthName\n */\n monthName: JewishMonthType;\n\n /**\n * month\n */\n year: number;\n}\n\nexport interface JewishDate extends BasicJewishDate {\n /**\n * month\n */\n month: number;\n}\n\nexport interface BasicJewishDateHebrew {\n /**\n * day of month\n */\n day: string;\n\n /**\n * monthName\n */\n monthName: string;\n\n /**\n * month\n */\n year: string;\n}\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nconst GREGORIAN_EPOCH = 1721425.5;\n\nconst HEBREW_EPOCH = 347995.5;\n\n/**\n * Computes the remainder of the division of `a` by `b`.\n * Unlike the built-in JavaScript `%` operator, this function handles negative numbers properly.\n * For example, `mod(-1, 5)` returns `4`, not `-1`.\n * @param {number} a - The number to compute the remainder of.\n * @param {number} b - The divisor.\n * @returns {number} - The remainder of `a` divided by `b`.\n */\nexport function mod(a: number, b: number) {\n return a - b * Math.floor(a / b);\n}\n\n/**\n * Determines if a given year is a leap year in the Gregorian calendar.\n * @param year The year to check.\n * @returns True if the year is a leap year, false otherwise.\n */\nfunction leapGregorian(year: number) {\n return year % 4 === 0 && !(year % 100 === 0 && year % 400 !== 0);\n}\n\n/**\n * Converts Gregorian date to Julian Day.\n * @param {number} year - The year in the Gregorian calendar.\n * @param {number} month - The month in the Gregorian calendar (January = 1).\n * @param {number} day - The day of the month in the Gregorian calendar.\n * @returns {number} The Julian Day corresponding to the Gregorian date.\n */\nexport function gregorianToJd(\n year: number,\n month: number,\n day: number,\n): number {\n return (\n GREGORIAN_EPOCH -\n 1 +\n 365 * (year - 1) +\n Math.floor((year - 1) / 4) +\n -Math.floor((year - 1) / 100) +\n Math.floor((year - 1) / 400) +\n Math.floor(\n (367 * month - 362) / 12 +\n (month <= 2 ? 0 : leapGregorian(year) ? -1 : -2) +\n day,\n )\n );\n}\n\n/**\n * Converts a Julian day number to Gregorian date.\n * @param {number} jd - The Julian day number to convert.\n * @returns {[number, number, number]} The Gregorian date as a tuple in the form of [year, month, day].\n */\nexport function jdToGregorian(jd: number): [number, number, number] {\n const wjd: number = Math.floor(jd - 0.5) + 0.5;\n const depoch: number = wjd - GREGORIAN_EPOCH;\n const quadricent: number = Math.floor(depoch / 146097);\n const dqc: number = mod(depoch, 146097);\n const cent: number = Math.floor(dqc / 36524);\n const dcent: number = mod(dqc, 36524);\n const quad: number = Math.floor(dcent / 1461);\n const dquad: number = mod(dcent, 1461);\n const yindex: number = Math.floor(dquad / 365);\n let year: number = quadricent * 400 + cent * 100 + quad * 4 + yindex;\n if (!(cent === 4 || yindex === 4)) {\n year++;\n }\n const yearday: number = wjd - gregorianToJd(year, 1, 1);\n const leapadj: number =\n wjd < gregorianToJd(year, 3, 1) ? 0 : leapGregorian(year) ? 1 : 2;\n const month: number = Math.floor(((yearday + leapadj) * 12 + 373) / 367);\n const day: number = wjd - gregorianToJd(year, month, 1) + 1;\n\n return [year, month, day];\n}\n\n/**\n * Determines if a Hebrew year is a leap year.\n * A leap year occurs 7 times in a 19 year cycle.\n * @param year - the Hebrew year to check\n * @returns true if the year is a leap year, false otherwise\n */\nfunction hebrewLeap(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n/**\n * Returns the number of months in a Hebrew year\n * @param {number} year - The Hebrew year\n * @returns {number} The number of months in the Hebrew year (12 or 13)\n */\nfunction hebrewYearMonths(year: number) {\n return hebrewLeap(year) ? 13 : 12;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year, taking into account the \"dechiya\" (postponement) rules\n * specified in the Mishnah, which state that the start of the year can't be Sunday, Wednesday, or Friday.\n * @param {number} year - The Hebrew year for which to calculate the delay.\n * @returns {number} The day of the molad (the moment of the astronomical new moon) for the specified Hebrew year.\n */\nfunction calculateHebrewYearStartDelay(year: number) {\n const months = Math.floor((235 * year - 234) / 19);\n const parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day++;\n }\n return day;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year due to the length of adjacent years,\n * taking into account the \"dechiya\" (postponement) rules specified in the Mishnah.\n * The rules state that if the length of the year that is next in the 19-year cycle\n * (i.e., in the year after the current year) is exactly 356 days, then the start of the current year\n * is delayed by two days. Similarly, if the length of the year that immediately precedes the current year\n * is 382 days, then the start of the current year is delayed by one day. Otherwise, there is no delay.\n *\n * @param year - The Hebrew year for which to calculate the delay.\n * @returns The delay in days of the start of the Hebrew year.\n */\nfunction calculateHebrewYearAdjacentDelay(year: number) {\n const last = calculateHebrewYearStartDelay(year - 1);\n const present = calculateHebrewYearStartDelay(year);\n const next = calculateHebrewYearStartDelay(year + 1);\n\n return next - present === 356 ? 2 : present - last === 382 ? 1 : 0;\n}\n\n/**\n * Calculates the number of days in a Hebrew year.\n * @param {number} year - The Hebrew year to calculate.\n * @returns {number} - The number of days in the Hebrew year.\n */\nfunction hebrewYearDays(year: number) {\n return hebrewToJd(year + 1, 7, 1) - hebrewToJd(year, 7, 1);\n}\n\n/**\n * Calculates the number of days in the specified month of the Hebrew year.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The month of the year, where Nisan is 1 and Adar II (in leap years) is 13.\n * @returns {number} - The number of days in the specified month.\n */\nexport function hebrewMonthDays(year: number, month: number) {\n if (\n month === 2 ||\n month === 4 ||\n month === 6 ||\n month === 10 ||\n month === 13\n ) {\n return 29;\n }\n\n if (month === 12 && !hebrewLeap(year)) {\n return 29;\n }\n\n if (month === 8 && !(mod(hebrewYearDays(year), 10) === 5)) {\n return 29;\n }\n\n if (month === 9 && mod(hebrewYearDays(year), 10) === 3) {\n return 29;\n }\n\n return 30;\n}\n\n/**\n * Converts a Hebrew date to the corresponding Julian day.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The Hebrew month (1-13).\n * @param {number} day - The day of the month.\n * @returns {number} The Julian day corresponding to the Hebrew date.\n */\nexport function hebrewToJd(year: number, month: number, day: number) {\n let mon: number;\n\n const months = hebrewYearMonths(year);\n let jd =\n HEBREW_EPOCH +\n calculateHebrewYearStartDelay(year) +\n calculateHebrewYearAdjacentDelay(year) +\n day +\n 1;\n\n if (month < 7) {\n for (mon = 7; mon <= months; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n for (mon = 1; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n } else {\n for (mon = 7; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n }\n\n return jd;\n}\n\n/**\n * Converts a Julian date to a Hebrew date.\n * @param jd - The Julian date to convert.\n * @returns The Hebrew date as a tuple in the form of [year, month, day].\n */\nexport function jdToHebrew(julianDate: number): [number, number, number] {\n const HEBREW_EPOCH = 347995.5;\n let year: number;\n let month: number;\n\n const jd = Math.floor(julianDate) + 0.5;\n const count: number = Math.floor(\n ((jd - HEBREW_EPOCH) * 98496.0) / 35975351.0,\n );\n year = count - 1;\n for (let i = count; jd >= hebrewToJd(i, 7, 1); i++) {\n year++;\n }\n const first: number = jd < hebrewToJd(year, 1, 1) ? 7 : 1;\n month = first;\n for (let i = first; jd > hebrewToJd(year, i, hebrewMonthDays(year, i)); i++) {\n month++;\n }\n const day = jd - hebrewToJd(year, month, 1) + 1;\n return [year, month, day];\n}\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\n/**\n * Pads a number with leading zeros until it reaches the desired length.\n * @param num - The number to pad.\n * @param len - The desired length of the padded number.\n * @returns A string representation of the padded number.\n */\nexport const toLength = (num: number, len: number) => {\n return num.toString().padStart(len, \"0\");\n};\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nimport {\n BasicJewishDate,\n JewishDate,\n JewishMonth,\n JewishMonthType,\n} from \"./interfaces\";\nimport {\n gregorianToJd,\n hebrewMonthDays,\n hebrewToJd,\n jdToGregorian,\n jdToHebrew,\n} from \"./utils/dateUtils\";\nimport { toLength } from \"./utils/numberUtils\";\n\n/**\n * Checks if the given year is a leap year according to the Jewish calendar.\n * @param {number} year - The year to check.\n * @returns {boolean} True if the given year is a leap year according to the Jewish calendar, false otherwise.\n */\nexport const isLeapYear = (year: number): boolean => {\n const yearIndex = year % 19;\n return (\n yearIndex === 0 ||\n yearIndex === 3 ||\n yearIndex === 6 ||\n yearIndex === 8 ||\n yearIndex === 11 ||\n yearIndex === 14 ||\n yearIndex === 17\n );\n};\n\n/**\n * Returns the index of the given Jewish month in the Jewish calendar.\n * @param {JewishMonthType} jewishMonth - The Jewish month to get the index for.\n * @returns {number} The index of the given Jewish month in the Jewish calendar.\n */\nexport const getIndexByJewishMonth = (jewishMonth: JewishMonthType): number => {\n const jewishMonthsNamesDic = {\n [JewishMonth.None]: 0,\n\n [JewishMonth.Tishri]: 7,\n [JewishMonth.Cheshvan]: 8,\n [JewishMonth.Kislev]: 9,\n [JewishMonth.Tevet]: 10,\n [JewishMonth.Shevat]: 11,\n [JewishMonth.Adar]: 12,\n [JewishMonth.AdarI]: 12,\n [JewishMonth.AdarII]: 13,\n [JewishMonth.Nisan]: 1,\n [JewishMonth.Iyyar]: 2,\n [JewishMonth.Sivan]: 3,\n [JewishMonth.Tammuz]: 4,\n [JewishMonth.Av]: 5,\n [JewishMonth.Elul]: 6,\n };\n return jewishMonthsNamesDic[jewishMonth] || 0;\n};\n\n/**\n * Returns the Jewish month corresponding to the given index in the Jewish calendar of the given year.\n * @param {number} index - The index of the Jewish month to get (1-based).\n * @param {number} jewishYear - The year to get the Jewish month in.\n * @returns {JewishMonthType} The Jewish month corresponding to the given index in the Jewish calendar of the given year.\n */\nexport const getJewishMonthByIndex = (\n index: number,\n jewishYear: number,\n): JewishMonthType => {\n const jewishMonths: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.Adar,\n JewishMonth.AdarII,\n ];\n\n const month = jewishMonths[index] || JewishMonth.None;\n if (month === JewishMonth.Adar && isLeapYear(jewishYear)) {\n return JewishMonth.AdarI;\n }\n return month;\n};\n\n/**\n * Returns an array of the Jewish month names in the correct order for the given year.\n * @param {number} year - The Jewish year to get the months for.\n * @returns {string[]} An array of the Jewish month names in the correct order for the given year.\n * */\nexport const getJewishMonthsInOrder = (year: number): string[] => {\n const jewishMonthsInOrder: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.AdarI,\n JewishMonth.AdarII,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n ];\n if (isLeapYear(year)) {\n return jewishMonthsInOrder;\n }\n\n return jewishMonthsInOrder\n .filter((month) => month !== \"AdarII\")\n .map((month) => {\n if (month === \"AdarI\") {\n return \"Adar\";\n }\n\n return month;\n });\n};\n\n/**\n * Returns a string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n * @param {JewishDate} jewishDate - The Jewish date to format.\n * @returns {string} A string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n */\nexport const formatJewishDate = (jewishDate: JewishDate): string => {\n return `${jewishDate.day} ${jewishDate.monthName} ${jewishDate.year}`;\n};\n\n/**\n * Converts the given Gregorian date to a Jewish date.\n * @param {Date} date - The Gregorian date to convert.\n * @returns {JewishDate} The Jewish date corresponding to the given Gregorian date.\n */\nexport const toJewishDate = (date: Date): JewishDate => {\n const year = date.getFullYear();\n const month = date.getMonth() + 1;\n const day = date.getDate();\n // console.log({ year, month, day });\n const jd2 = gregorianToJd(year, month, day);\n\n const jewishDateArr = jdToHebrew(jd2);\n // console.log(jewishDateArr);\n\n const jewishYear = jewishDateArr[0];\n const jewishMonthName = getJewishMonthByIndex(jewishDateArr[1], jewishYear);\n // console.log({ jewishMonthName });\n const jewishMonth = getJewishMonthsInOrder(jewishYear).findIndex(\n (i) => i === jewishMonthName,\n );\n const JewishDate: JewishDate = {\n year: jewishYear,\n monthName: jewishMonthName,\n month: jewishMonth,\n day: jewishDateArr[2],\n };\n return JewishDate;\n};\n\n/**\n * Converts the given Jewish date to a Gregorian date.\n * @param {BasicJewishDate} jewishDate - The Jewish date to convert.\n * @returns {Date} The Gregorian date corresponding to the given Jewish date.\n * */\nexport const toGregorianDate = (jewishDate: BasicJewishDate): Date => {\n const jewishMonth = getIndexByJewishMonth(jewishDate.monthName);\n // console.log({ jewishMonth });\n const jd = hebrewToJd(jewishDate.year, jewishMonth, jewishDate.day);\n // console.log(jd);\n\n const gregDateArr = jdToGregorian(jd);\n // console.log(gregDateArr);\n const dateStr = `${toLength(gregDateArr[0], 4)}-${toLength(\n gregDateArr[1],\n 2,\n )}-${toLength(gregDateArr[2], 2)}`;\n // console.log(dateStr);\n\n const date = new Date(dateStr);\n if (date.getHours() > 0) {\n // fix issue in chrome that we chan't set hours in Date Constructor for year 0000\n date.setHours(0, 0, 0, 0);\n }\n return date;\n};\n\n/**\n * Calculates the number of days in a Jewish month for a given Jewish year.\n * @param {number} jewishYear - The Jewish year for which the calculation is performed.\n * @param {JewishMonthType} jewishMonth - The type of Jewish month (e.g., 'Heshvan', 'Kislev').\n * @returns {number} - The number of days in the specified Jewish month of the given year.\n */\nexport const calcDaysInMonth = (\n jewishYear: number,\n jewishMonth: JewishMonthType,\n): number => {\n const jewishMonthIndex = getIndexByJewishMonth(jewishMonth);\n return hebrewMonthDays(jewishYear, jewishMonthIndex);\n};\n", "/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nimport gematriya from \"gematriya\";\nimport {\n BasicJewishDate,\n BasicJewishDateHebrew,\n JewishMonth,\n JewishMonthType,\n} from \"./interfaces\";\n\n/**\n * Returns the name of a Jewish month in Hebrew, given its type.\n * @param {JewishMonthType} jewishMonth - The Jewish month type.\n * @returns {string} - The name of the Jewish month in Hebrew.\n */\nexport const getJewishMonthInHebrew = (\n jewishMonth: JewishMonthType,\n): string => {\n const jewishMonthsHebrewNamesDic = {\n [JewishMonth.None]: \"\u05DC\u05DC\u05D0\",\n\n [JewishMonth.Tishri]: \"\u05EA\u05E9\u05E8\u05D9\",\n [JewishMonth.Cheshvan]: \"\u05D7\u05E9\u05D5\u05DF\",\n [JewishMonth.Kislev]: \"\u05DB\u05E1\u05DC\u05D5\",\n [JewishMonth.Tevet]: \"\u05D8\u05D1\u05EA\",\n [JewishMonth.Shevat]: \"\u05E9\u05D1\u05D8\",\n [JewishMonth.Adar]: \"\u05D0\u05D3\u05E8\",\n [JewishMonth.AdarI]: \"\u05D0\u05D3\u05E8 \u05D0\",\n [JewishMonth.AdarII]: \"\u05D0\u05D3\u05E8 \u05D1\",\n [JewishMonth.Nisan]: \"\u05E0\u05D9\u05E1\u05DF\",\n [JewishMonth.Iyyar]: \"\u05D0\u05D9\u05D9\u05E8\",\n [JewishMonth.Sivan]: \"\u05E1\u05D9\u05D5\u05DF\",\n [JewishMonth.Tammuz]: \"\u05EA\u05DE\u05D5\u05D6\",\n [JewishMonth.Av]: \"\u05D0\u05D1\",\n [JewishMonth.Elul]: \"\u05D0\u05DC\u05D5\u05DC\",\n };\n return jewishMonthsHebrewNamesDic[jewishMonth];\n};\n\n/**\n * Converts a number to its Hebrew equivalent in gematria\n * @param num - The number to convert to Hebrew\n * @param addGeresh - Whether or not to add a geresh symbol (') to the end of the number\n * @param addPunctuate - Whether or not to add a punctuation mark (.) after the thousands digit\n * @returns The Hebrew equivalent of the given number\n */\nexport const convertNumberToHebrew = (\n num: number,\n addGeresh = true,\n addPunctuate = true,\n): string => {\n return gematriya(num, { geresh: addGeresh, punctuate: addPunctuate });\n};\n\n/**\n * Converts a basic Jewish date object to a Hebrew date object with Hebrew letters.\n * @param {BasicJewishDate} jewishDate - The basic Jewish date object to convert.\n * @returns {BasicJewishDateHebrew} The Hebrew date object with Hebrew letters.\n */\nexport const toHebrewJewishDate = (\n jewishDate: BasicJewishDate,\n): BasicJewishDateHebrew => {\n return {\n day: convertNumberToHebrew(jewishDate.day),\n monthName: getJewishMonthInHebrew(jewishDate.monthName),\n year: convertNumberToHebrew(jewishDate.year),\n };\n};\n\n/**\n * Formats a Jewish date object into a string representation in Hebrew.\n * @param {BasicJewishDate} jewishDate - The Jewish date object to format.\n * @returns {string} The Hebrew string representation of the Jewish date.\n */\nexport const formatJewishDateInHebrew = (\n jewishDate: BasicJewishDate,\n): string => {\n const jewishDateInHebrew = toHebrewJewishDate(jewishDate);\n return `${jewishDateInHebrew.day} ${jewishDateInHebrew.monthName} ${jewishDateInHebrew.year}`;\n};\n"],
5
+ "mappings": "6iBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,qBAAAC,EAAA,6BAAAC,EAAA,0BAAAC,EAAA,0BAAAC,EAAA,2BAAAC,EAAA,2BAAAC,EAAA,eAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAf,ICQO,IAAMgB,EAAc,CACzB,KAAM,OAEN,OAAQ,SACR,SAAU,WACV,OAAQ,SACR,MAAO,QACP,OAAQ,SACR,KAAM,OACN,MAAO,QACP,MAAO,QACP,MAAO,QACP,OAAQ,SACR,GAAI,KACJ,KAAM,OAEN,MAAO,QACP,OAAQ,QACV,EClBA,IAAMC,EAAkB,YAElBC,EAAe,SAUd,SAASC,EAAIC,EAAWC,EAAW,CACxC,OAAOD,EAAIC,EAAI,KAAK,MAAMD,EAAIC,CAAC,CACjC,CAOA,SAASC,EAAcC,EAAc,CACnC,OAAOA,EAAO,IAAM,GAAK,EAAEA,EAAO,MAAQ,GAAKA,EAAO,MAAQ,EAChE,CASO,SAAS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L,IAAKN,EAAsBM,EAAW,GAAG,EACzC,UAAWT,EAAuBS,EAAW,SAAS,EACtD,KAAMN,EAAsBM,EAAW,IAAI,CAC7C,GAQWC,EACXD,GACW,CACX,IAAME,EAAqBH,EAAmBC,CAAU,EACxD,MAAO,GAAGE,EAAmB,GAAG,IAAIA,EAAmB,SAAS,IAAIA,EAAmB,IAAI,EAC7F",
6
+ "names": ["src_exports", "__export", "JewishMonth", "calcDaysInMonth", "convertNumberToHebrew", "formatJewishDate", "formatJewishDateInHebrew", "getIndexByJewishMonth", "getJewishMonthByIndex", "getJewishMonthInHebrew", "getJewishMonthsInOrder", "isLeapYear", "toGregorianDate", "toHebrewJewishDate", "toJewishDate", "__toCommonJS", "JewishMonth", "GREGORIAN_EPOCH", "HEBREW_EPOCH", "mod", "a", "b", "leapGregorian", "year", "gregorianToJd", "month", "day", "jdToGregorian", "jd", "wjd", "depoch", "quadricent", "dqc", "cent", "dcent", "quad", "dquad", "yindex", "yearday", "leapadj", "hebrewLeap", "hebrewYearMonths", "calculateHebrewYearStartDelay", "months", "parts", "calculateHebrewYearAdjacentDelay", "last", "present", "hebrewYearDays", "hebrewToJd", "hebrewMonthDays", "mon", "jdToHebrew", "julianDate", "count", "first", "toLength", "num", "len", "isLeapYear", "year", "yearIndex", "getIndexByJewishMonth", "jewishMonth", "JewishMonth", "getJewishMonthByIndex", "index", "jewishYear", "month", "getJewishMonthsInOrder", "jewishMonthsInOrder", "formatJewishDate", "jewishDate", "toJewishDate", "date", "day", "jd2", "gregorianToJd", "jewishDateArr", "jdToHebrew", "jewishMonthName", "i", "toGregorianDate", "jd", "hebrewToJd", "gregDateArr", "jdToGregorian", "dateStr", "toLength", "calcDaysInMonth", "jewishMonthIndex", "hebrewMonthDays", "import_gematriya", "getJewishMonthInHebrew", "jewishMonth", "JewishMonth", "convertNumberToHebrew", "num", "addGeresh", "addPunctuate", "gematriya", "toHebrewJewishDate", "jewishDate", "formatJewishDateInHebrew", "jewishDateInHebrew"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{JewishMonth as e}from"./interfaces";import{gregorianToJd as u,hebrewToJd as y,jdToGregorian as J,jdToHebrew as I}from"./utils/dateUtils";import{toLength as i}from"./utils/numberUtils";const m=t=>{const n=t%19;return n===0||n===3||n===6||n===8||n===11||n===14||n===17},v=t=>({[e.None]:0,[e.Tishri]:7,[e.Cheshvan]:8,[e.Kislev]:9,[e.Tevet]:10,[e.Shevat]:11,[e.Adar]:12,[e.AdarI]:12,[e.AdarII]:13,[e.Nisan]:1,[e.Iyyar]:2,[e.Sivan]:3,[e.Tammuz]:4,[e.Av]:5,[e.Elul]:6})[t]||0,M=(t,n)=>{const s=[e.None,e.Nisan,e.Iyyar,e.Sivan,e.Tammuz,e.Av,e.Elul,e.Tishri,e.Cheshvan,e.Kislev,e.Tevet,e.Shevat,e.Adar,e.AdarII][t]||e.None;return s===e.Adar&&m(n)?e.AdarI:s},T=t=>{const n=[e.None,e.Tishri,e.Cheshvan,e.Kislev,e.Tevet,e.Shevat,e.AdarI,e.AdarII,e.Nisan,e.Iyyar,e.Sivan,e.Tammuz,e.Av,e.Elul];return m(t)?n:n.filter(r=>r!=="AdarII").map(r=>r==="AdarI"?"Adar":r)},j=t=>`${t.day} ${t.monthName} ${t.year}`,b=t=>{const n=t.getFullYear(),r=t.getMonth()+1,s=t.getDate(),a=u(n,r,s),o=I(a),h=o[0],c=M(o[1],h),w=T(h).findIndex(d=>d===c);return{year:h,monthName:c,month:w,day:o[2]}},S=t=>{const n=v(t.monthName),r=y(t.year,n,t.day),s=J(r),a=`${i(s[0],4)}-${i(s[1],2)}-${i(s[2],2)}`,o=new Date(a);return o.getHours()>0&&o.setHours(0,0,0,0),o};export{j as formatJewishDate,v as getIndexByJewishMonth,M as getJewishMonthByIndex,T as getJewishMonthsInOrder,m as isLeapYear,S as toGregorianDate,b as toJewishDate};
1
+ import{JewishMonth as e}from"./interfaces";import{gregorianToJd as y,hebrewMonthDays as I,hebrewToJd as J,jdToGregorian as M,jdToHebrew as p}from"./utils/dateUtils";import{toLength as i}from"./utils/numberUtils";const m=t=>{const n=t%19;return n===0||n===3||n===6||n===8||n===11||n===14||n===17},w=t=>({[e.None]:0,[e.Tishri]:7,[e.Cheshvan]:8,[e.Kislev]:9,[e.Tevet]:10,[e.Shevat]:11,[e.Adar]:12,[e.AdarI]:12,[e.AdarII]:13,[e.Nisan]:1,[e.Iyyar]:2,[e.Sivan]:3,[e.Tammuz]:4,[e.Av]:5,[e.Elul]:6})[t]||0,T=(t,n)=>{const o=[e.None,e.Nisan,e.Iyyar,e.Sivan,e.Tammuz,e.Av,e.Elul,e.Tishri,e.Cheshvan,e.Kislev,e.Tevet,e.Shevat,e.Adar,e.AdarII][t]||e.None;return o===e.Adar&&m(n)?e.AdarI:o},v=t=>{const n=[e.None,e.Tishri,e.Cheshvan,e.Kislev,e.Tevet,e.Shevat,e.AdarI,e.AdarII,e.Nisan,e.Iyyar,e.Sivan,e.Tammuz,e.Av,e.Elul];return m(t)?n:n.filter(r=>r!=="AdarII").map(r=>r==="AdarI"?"Adar":r)},j=t=>`${t.day} ${t.monthName} ${t.year}`,f=t=>{const n=t.getFullYear(),r=t.getMonth()+1,o=t.getDate(),a=y(n,r,o),s=p(a),h=s[0],c=T(s[1],h),d=v(h).findIndex(u=>u===c);return{year:h,monthName:c,month:d,day:s[2]}},S=t=>{const n=w(t.monthName),r=J(t.year,n,t.day),o=M(r),a=`${i(o[0],4)}-${i(o[1],2)}-${i(o[2],2)}`,s=new Date(a);return s.getHours()>0&&s.setHours(0,0,0,0),s},$=(t,n)=>{const r=w(n);return I(t,r)};export{$ as calcDaysInMonth,j as formatJewishDate,w as getIndexByJewishMonth,T as getJewishMonthByIndex,v as getJewishMonthsInOrder,m as isLeapYear,S as toGregorianDate,f as toJewishDate};
2
2
  //# sourceMappingURL=jewishDate.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/jewishDate.ts"],
4
- "sourcesContent": ["/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nimport {\n BasicJewishDate,\n JewishDate,\n BasicJewishDateHebrew,\n JewishMonth,\n JewishMonthType,\n} from \"./interfaces\";\nimport {\n gregorianToJd,\n hebrewToJd,\n jdToGregorian,\n jdToHebrew,\n} from \"./utils/dateUtils\";\nimport { toLength } from \"./utils/numberUtils\";\n\n/**\n * Checks if the given year is a leap year according to the Jewish calendar.\n * @param {number} year - The year to check.\n * @returns {boolean} True if the given year is a leap year according to the Jewish calendar, false otherwise.\n */\nexport const isLeapYear = (year: number): boolean => {\n const yearIndex = year % 19;\n return (\n yearIndex === 0 ||\n yearIndex === 3 ||\n yearIndex === 6 ||\n yearIndex === 8 ||\n yearIndex === 11 ||\n yearIndex === 14 ||\n yearIndex === 17\n );\n};\n\n/**\n * Returns the index of the given Jewish month in the Jewish calendar.\n * @param {JewishMonthType} jewishMonth - The Jewish month to get the index for.\n * @returns {number} The index of the given Jewish month in the Jewish calendar.\n */\nexport const getIndexByJewishMonth = (jewishMonth: JewishMonthType): number => {\n const jewishMonthsNamesDic = {\n [JewishMonth.None]: 0,\n\n [JewishMonth.Tishri]: 7,\n [JewishMonth.Cheshvan]: 8,\n [JewishMonth.Kislev]: 9,\n [JewishMonth.Tevet]: 10,\n [JewishMonth.Shevat]: 11,\n [JewishMonth.Adar]: 12,\n [JewishMonth.AdarI]: 12,\n [JewishMonth.AdarII]: 13,\n [JewishMonth.Nisan]: 1,\n [JewishMonth.Iyyar]: 2,\n [JewishMonth.Sivan]: 3,\n [JewishMonth.Tammuz]: 4,\n [JewishMonth.Av]: 5,\n [JewishMonth.Elul]: 6,\n };\n return jewishMonthsNamesDic[jewishMonth] || 0;\n};\n\n/**\n * Returns the Jewish month corresponding to the given index in the Jewish calendar of the given year.\n * @param {number} index - The index of the Jewish month to get (1-based).\n * @param {number} jewishYear - The year to get the Jewish month in.\n * @returns {JewishMonthType} The Jewish month corresponding to the given index in the Jewish calendar of the given year.\n */\nexport const getJewishMonthByIndex = (\n index: number,\n jewishYear: number,\n): JewishMonthType => {\n const jewishMonths: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.Adar,\n JewishMonth.AdarII,\n ];\n\n const month = jewishMonths[index] || JewishMonth.None;\n if (month === JewishMonth.Adar && isLeapYear(jewishYear)) {\n return JewishMonth.AdarI;\n }\n return month;\n};\n\n/**\n * Returns an array of the Jewish month names in the correct order for the given year.\n * @param {number} year - The Jewish year to get the months for.\n * @returns {string[]} An array of the Jewish month names in the correct order for the given year.\n * */\nexport const getJewishMonthsInOrder = (year: number): string[] => {\n const jewishMonthsInOrder: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.AdarI,\n JewishMonth.AdarII,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n ];\n if (isLeapYear(year)) {\n return jewishMonthsInOrder;\n } else {\n return jewishMonthsInOrder\n .filter((month) => month !== \"AdarII\")\n .map((month) => {\n if (month === \"AdarI\") {\n return \"Adar\";\n } else {\n return month;\n }\n });\n }\n};\n\n/**\n * Returns a string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n * @param {JewishDate} jewishDate - The Jewish date to format.\n * @returns {string} A string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n */\nexport const formatJewishDate = (jewishDate: JewishDate): string => {\n return `${jewishDate.day} ${jewishDate.monthName} ${jewishDate.year}`;\n};\n\n/**\n * Converts the given Gregorian date to a Jewish date.\n * @param {Date} date - The Gregorian date to convert.\n * @returns {JewishDate} The Jewish date corresponding to the given Gregorian date.\n */\nexport const toJewishDate = (date: Date): JewishDate => {\n const year = date.getFullYear();\n const month = date.getMonth() + 1;\n const day = date.getDate();\n // console.log({ year, month, day });\n const jd2 = gregorianToJd(year, month, day);\n\n const jewishDateArr = jdToHebrew(jd2);\n // console.log(jewishDateArr);\n\n const jewishYear = jewishDateArr[0];\n const jewishMonthName = getJewishMonthByIndex(jewishDateArr[1], jewishYear);\n // console.log({ jewishMonthName });\n const jewishMonth = getJewishMonthsInOrder(jewishYear).findIndex(\n (i) => i === jewishMonthName,\n );\n const JewishDate: JewishDate = {\n year: jewishYear,\n monthName: jewishMonthName,\n month: jewishMonth,\n day: jewishDateArr[2],\n };\n return JewishDate;\n};\n\n/**\n * Converts the given Jewish date to a Gregorian date.\n * @param {BasicJewishDate} jewishDate - The Jewish date to convert.\n * @returns {Date} The Gregorian date corresponding to the given Jewish date.\n * */\nexport const toGregorianDate = (jewishDate: BasicJewishDate): Date => {\n const jewishMonth = getIndexByJewishMonth(jewishDate.monthName);\n // console.log({ jewishMonth });\n const jd = hebrewToJd(jewishDate.year, jewishMonth, jewishDate.day);\n // console.log(jd);\n\n const gregDateArr = jdToGregorian(jd);\n // console.log(gregDateArr);\n const dateStr = `${toLength(gregDateArr[0], 4)}-${toLength(\n gregDateArr[1],\n 2,\n )}-${toLength(gregDateArr[2], 2)}`;\n // console.log(dateStr);\n\n const date = new Date(dateStr);\n if (date.getHours() > 0) {\n // fix issue in chrome that we chan't set hours in Date Constructor for year 0000\n date.setHours(0, 0, 0, 0);\n }\n return date;\n};\n"],
5
- "mappings": "AAQA,OAIE,eAAAA,MAEK,eACP,OACE,iBAAAC,EACA,cAAAC,EACA,i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OACZA,EAAY,GACZA,EAAY,IACd,EACA,OAAIM,EAAWC,CAAI,EACVS,EAEAA,EACJ,OAAQF,GAAUA,IAAU,QAAQ,EACpC,IAAKA,GACAA,IAAU,QACL,OAEAA,CAEV,CAEP,EAOaG,EAAoBC,GACxB,GAAGA,EAAW,GAAG,IAAIA,EAAW,SAAS,IAAIA,EAAW,IAAI,GAQxDC,EAAgBC,GAA2B,CACtD,MAAMb,EAAOa,EAAK,YAAY,EACxBN,EAAQM,EAAK,SAAS,EAAI,EAC1BC,EAAMD,EAAK,QAAQ,EAEnBE,EAAMrB,EAAcM,EAAMO,EAAOO,CAAG,EAEpCE,EAAgBnB,EAAWkB,CAAG,EAG9BT,EAAaU,EAAc,CAAC,EAC5BC,EAAkBb,EAAsBY,EAAc,CAAC,EAAGV,CAAU,EAEpEH,EAAcK,EAAuBF,CAAU,EAAE,UACpDY,GAAMA,IAAMD,CACf,EAOA,MAN+B,CAC7B,KAAMX,EACN,UAAWW,EACX,MAAOd,EACP,IAAKa,EAAc,CAAC,CACtB,CAEF,EAOaG,EAAmBR,GAAsC,CACpE,MAAMR,EAAcD,EAAsBS,EAAW,SAAS,EAExDS,EAAKzB,EAAWgB,EAAW,KAAMR,EAAaQ,EAAW,GAAG,EAG5DU,EAAczB,EAAcwB,CAAE,EAE9BE,EAAU,GAAGxB,EAASuB,EAAY,CAAC,EAAG,CAAC,CAAC,IAAIvB,EAChDuB,EAAY,CAAC,EACb,CACF,CAAC,IAAIvB,EAASuB,EAAY,CAAC,EAAG,CAAC,CAAC,GAG1BR,EAAO,IAAI,KAAKS,CAAO,EAC7B,OAAIT,EAAK,SAAS,EAAI,GAEpBA,EAAK,SAAS,EAAG,EAAG,EAAG,CAAC,EAEnBA,CACT",
6
- "names": ["JewishMonth", "gregorianToJd", "hebrewToJd", "jdToGregorian", "jdToHebrew", "toLength", "isLeapYear", "year", "yearIndex", "getIndexByJewishMonth", "jewishMonth", "getJewishMonthByIndex", "index", "jewishYear", "month", "getJewishMonthsInOrder", "jewishMonthsInOrder", "formatJewishDate", "jewishDate", "toJewishDate", "date", "day", "jd2", "jewishDateArr", "jewishMonthName", "i", "toGregorianDate", "jd", "gregDateArr", "dateStr"]
4
+ "sourcesContent": ["/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nimport {\n BasicJewishDate,\n JewishDate,\n JewishMonth,\n JewishMonthType,\n} from \"./interfaces\";\nimport {\n gregorianToJd,\n hebrewMonthDays,\n hebrewToJd,\n jdToGregorian,\n jdToHebrew,\n} from \"./utils/dateUtils\";\nimport { toLength } from \"./utils/numberUtils\";\n\n/**\n * Checks if the given year is a leap year according to the Jewish calendar.\n * @param {number} year - The year to check.\n * @returns {boolean} True if the given year is a leap year according to the Jewish calendar, false otherwise.\n */\nexport const isLeapYear = (year: number): boolean => {\n const yearIndex = year % 19;\n return (\n yearIndex === 0 ||\n yearIndex === 3 ||\n yearIndex === 6 ||\n yearIndex === 8 ||\n yearIndex === 11 ||\n yearIndex === 14 ||\n yearIndex === 17\n );\n};\n\n/**\n * Returns the index of the given Jewish month in the Jewish calendar.\n * @param {JewishMonthType} jewishMonth - The Jewish month to get the index for.\n * @returns {number} The index of the given Jewish month in the Jewish calendar.\n */\nexport const getIndexByJewishMonth = (jewishMonth: JewishMonthType): number => {\n const jewishMonthsNamesDic = {\n [JewishMonth.None]: 0,\n\n [JewishMonth.Tishri]: 7,\n [JewishMonth.Cheshvan]: 8,\n [JewishMonth.Kislev]: 9,\n [JewishMonth.Tevet]: 10,\n [JewishMonth.Shevat]: 11,\n [JewishMonth.Adar]: 12,\n [JewishMonth.AdarI]: 12,\n [JewishMonth.AdarII]: 13,\n [JewishMonth.Nisan]: 1,\n [JewishMonth.Iyyar]: 2,\n [JewishMonth.Sivan]: 3,\n [JewishMonth.Tammuz]: 4,\n [JewishMonth.Av]: 5,\n [JewishMonth.Elul]: 6,\n };\n return jewishMonthsNamesDic[jewishMonth] || 0;\n};\n\n/**\n * Returns the Jewish month corresponding to the given index in the Jewish calendar of the given year.\n * @param {number} index - The index of the Jewish month to get (1-based).\n * @param {number} jewishYear - The year to get the Jewish month in.\n * @returns {JewishMonthType} The Jewish month corresponding to the given index in the Jewish calendar of the given year.\n */\nexport const getJewishMonthByIndex = (\n index: number,\n jewishYear: number,\n): JewishMonthType => {\n const jewishMonths: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.Adar,\n JewishMonth.AdarII,\n ];\n\n const month = jewishMonths[index] || JewishMonth.None;\n if (month === JewishMonth.Adar && isLeapYear(jewishYear)) {\n return JewishMonth.AdarI;\n }\n return month;\n};\n\n/**\n * Returns an array of the Jewish month names in the correct order for the given year.\n * @param {number} year - The Jewish year to get the months for.\n * @returns {string[]} An array of the Jewish month names in the correct order for the given year.\n * */\nexport const getJewishMonthsInOrder = (year: number): string[] => {\n const jewishMonthsInOrder: JewishMonthType[] = [\n JewishMonth.None,\n JewishMonth.Tishri,\n JewishMonth.Cheshvan,\n JewishMonth.Kislev,\n JewishMonth.Tevet,\n JewishMonth.Shevat,\n JewishMonth.AdarI,\n JewishMonth.AdarII,\n JewishMonth.Nisan,\n JewishMonth.Iyyar,\n JewishMonth.Sivan,\n JewishMonth.Tammuz,\n JewishMonth.Av,\n JewishMonth.Elul,\n ];\n if (isLeapYear(year)) {\n return jewishMonthsInOrder;\n }\n\n return jewishMonthsInOrder\n .filter((month) => month !== \"AdarII\")\n .map((month) => {\n if (month === \"AdarI\") {\n return \"Adar\";\n }\n\n return month;\n });\n};\n\n/**\n * Returns a string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n * @param {JewishDate} jewishDate - The Jewish date to format.\n * @returns {string} A string representation of the given Jewish date in the format '\u05DB\"\u05D0 \u05E0\u05D9\u05E1\u05DF \u05EA\u05E9\u05E4\"\u05D2'.\n */\nexport const formatJewishDate = (jewishDate: JewishDate): string => {\n return `${jewishDate.day} ${jewishDate.monthName} ${jewishDate.year}`;\n};\n\n/**\n * Converts the given Gregorian date to a Jewish date.\n * @param {Date} date - The Gregorian date to convert.\n * @returns {JewishDate} The Jewish date corresponding to the given Gregorian date.\n */\nexport const toJewishDate = (date: Date): JewishDate => {\n const year = date.getFullYear();\n const month = date.getMonth() + 1;\n const day = date.getDate();\n // console.log({ year, month, day });\n const jd2 = gregorianToJd(year, month, day);\n\n const jewishDateArr = jdToHebrew(jd2);\n // console.log(jewishDateArr);\n\n const jewishYear = jewishDateArr[0];\n const jewishMonthName = getJewishMonthByIndex(jewishDateArr[1], jewishYear);\n // console.log({ jewishMonthName });\n const jewishMonth = getJewishMonthsInOrder(jewishYear).findIndex(\n (i) => i === jewishMonthName,\n );\n const JewishDate: JewishDate = {\n year: jewishYear,\n monthName: jewishMonthName,\n month: jewishMonth,\n day: jewishDateArr[2],\n };\n return JewishDate;\n};\n\n/**\n * Converts the given Jewish date to a Gregorian date.\n * @param {BasicJewishDate} jewishDate - The Jewish date to convert.\n * @returns {Date} The Gregorian date corresponding to the given Jewish date.\n * */\nexport const toGregorianDate = (jewishDate: BasicJewishDate): Date => {\n const jewishMonth = getIndexByJewishMonth(jewishDate.monthName);\n // console.log({ jewishMonth });\n const jd = hebrewToJd(jewishDate.year, jewishMonth, jewishDate.day);\n // console.log(jd);\n\n const gregDateArr = jdToGregorian(jd);\n // console.log(gregDateArr);\n const dateStr = `${toLength(gregDateArr[0], 4)}-${toLength(\n gregDateArr[1],\n 2,\n )}-${toLength(gregDateArr[2], 2)}`;\n // console.log(dateStr);\n\n const date = new Date(dateStr);\n if (date.getHours() > 0) {\n // fix issue in chrome that we chan't set hours in Date Constructor for year 0000\n date.setHours(0, 0, 0, 0);\n }\n return date;\n};\n\n/**\n * Calculates the number of days in a Jewish month for a given Jewish year.\n * @param {number} jewishYear - The Jewish year for which the calculation is performed.\n * @param {JewishMonthType} jewishMonth - The type of Jewish month (e.g., 'Heshvan', 'Kislev').\n * @returns {number} - The number of days in the specified Jewish month of the given year.\n */\nexport const calcDaysInMonth = (\n jewishYear: number,\n jewishMonth: JewishMonthType,\n): number => {\n const jewishMonthIndex = getIndexByJewishMonth(jewishMonth);\n return hebrewMonthDays(jewishYear, jewishMonthIndex);\n};\n"],
5
+ "mappings": "AAQA,OAGE,eAAAA,MAEK,eACP,OACE,iBAAAC,EACA,mBAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,cAAAC,MACK,oBACP,OAAS,YAAAC,MAAgB,sBAOlB,MAAMC,EAAcC,GAA0B,CACnD,MAAMC,EAAYD,EAAO,GACzB,OACEC,IAAc,GACdA,IAAc,GACdA,IAAc,GACdA,IAAc,GACdA,IAAc,IACdA,IAAc,IACdA,IAAc,EAElB,EAOaC,EAAyBC,IACP,CAC3B,CAACX,EAAY,IAAI,EAAG,EAEpB,CAACA,EAAY,MAAM,EAAG,EACtB,CAACA,EAAY,QAAQ,EAAG,EACxB,CAACA,EAAY,MAAM,EAAG,EACtB,CAACA,EAAY,KAAK,EAAG,GACrB,CAACA,EAAY,MAAM,EAAG,GACtB,CAACA,EAAY,IAAI,EAAG,GACpB,CAACA,EAAY,KAAK,EAAG,GACrB,CAACA,EAAY,MAAM,EAAG,GACtB,CAACA,EAAY,KAAK,EAAG,EACrB,CAACA,EAAY,KAAK,EAAG,EACrB,CAACA,EAAY,KAAK,EAAG,EACrB,CAACA,EAAY,MAAM,EAAG,EACtB,CAACA,EAAY,EAAE,EAAG,EAClB,CAACA,EAAY,IAAI,EAAG,CACtB,GAC4BW,CAAW,GAAK,EASjCC,EAAwB,CACnCC,EACAC,IACoB,CAkBpB,MAAMC,EAjBkC,CACtCf,EAAY,K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U,EAAczB,EAAcwB,CAAE,EAE9BE,EAAU,GAAGxB,EAASuB,EAAY,CAAC,EAAG,CAAC,CAAC,IAAIvB,EAChDuB,EAAY,CAAC,EACb,CACF,CAAC,IAAIvB,EAASuB,EAAY,CAAC,EAAG,CAAC,CAAC,GAG1BR,EAAO,IAAI,KAAKS,CAAO,EAC7B,OAAIT,EAAK,SAAS,EAAI,GAEpBA,EAAK,SAAS,EAAG,EAAG,EAAG,CAAC,EAEnBA,CACT,EAQaU,EAAkB,CAC7BjB,EACAH,IACW,CACX,MAAMqB,EAAmBtB,EAAsBC,CAAW,EAC1D,OAAOT,EAAgBY,EAAYkB,CAAgB,CACrD",
6
+ "names": ["JewishMonth", "gregorianToJd", "hebrewMonthDays", "hebrewToJd", "jdToGregorian", "jdToHebrew", "toLength", "isLeapYear", "year", "yearIndex", "getIndexByJewishMonth", "jewishMonth", "getJewishMonthByIndex", "index", "jewishYear", "month", "getJewishMonthsInOrder", "jewishMonthsInOrder", "formatJewishDate", "jewishDate", "toJewishDate", "date", "day", "jd2", "jewishDateArr", "jewishMonthName", "i", "toGregorianDate", "jd", "gregDateArr", "dateStr", "calcDaysInMonth", "jewishMonthIndex"]
7
7
  }
@@ -1,2 +1,2 @@
1
- const p=17214255e-1,R=347995.5;function c(n,r){return n-r*Math.floor(n/r)}function E(n){return n%4===0&&!(n%100===0&&n%400!==0)}function d(n,r,t){return p-1+365*(n-1)+Math.floor((n-1)/4)+-Math.floor((n-1)/100)+Math.floor((n-1)/400)+Math.floor((367*r-362)/12+(r<=2?0:E(n)?-1:-2)+t)}function C(n){const r=Math.floor(n-.5)+.5,t=r-p,e=Math.floor(t/146097),o=c(t,146097),u=Math.floor(o/36524),s=c(o,36524),i=Math.floor(s/1461),b=c(s,1461),h=Math.floor(b/365);let f=e*400+u*100+i*4+h;u===4||h===4||f++;const x=r-d(f,1,1),j=r<d(f,3,1)?0:E(f)?1:2,M=Math.floor(((x+j)*12+373)/367),O=r-d(f,M,1)+1;return[f,M,O]}function H(n){return c(n*7+1,19)<7}function g(n){return H(n)?13:12}function l(n){const r=Math.floor((235*n-234)/19),t=12084+13753*r;let e=r*29+Math.floor(t/25920);return c(3*(e+1),7)<3&&e++,e}function q(n){const r=l(n-1),t=l(n);return l(n+1)-t===356?2:t-r===382?1:0}function w(n){return m(n+1,7,1)-m(n,7,1)}function a(n,r){return r===2||r===4||r===6||r===10||r===13||r===12&&!H(n)||r===8&&c(w(n),10)!==5||r===9&&c(w(n),10)===3?29:30}function m(n,r,t){let e;const o=g(n);let u=R+l(n)+q(n)+t+1;if(r<7){for(e=7;e<=o;e++)u+=a(n,e);for(e=1;e<r;e++)u+=a(n,e)}else for(e=7;e<r;e++)u+=a(n,e);return u}function D(n){let t,e;const o=Math.floor(n)+.5,u=Math.floor((o-347995.5)*98496/35975351);t=u-1;for(let b=u;o>=m(b,7,1);b++)t++;const s=o<m(t,1,1)?7:1;e=s;for(let b=s;o>m(t,b,a(t,b));b++)e++;const i=o-m(t,e,1)+1;return[t,e,i]}export{d as gregorianToJd,m as hebrewToJd,C as jdToGregorian,D as jdToHebrew,c as mod};
1
+ const p=17214255e-1,R=347995.5;function c(n,r){return n-r*Math.floor(n/r)}function E(n){return n%4===0&&!(n%100===0&&n%400!==0)}function d(n,r,t){return p-1+365*(n-1)+Math.floor((n-1)/4)+-Math.floor((n-1)/100)+Math.floor((n-1)/400)+Math.floor((367*r-362)/12+(r<=2?0:E(n)?-1:-2)+t)}function C(n){const r=Math.floor(n-.5)+.5,t=r-p,e=Math.floor(t/146097),o=c(t,146097),u=Math.floor(o/36524),s=c(o,36524),i=Math.floor(s/1461),b=c(s,1461),h=Math.floor(b/365);let f=e*400+u*100+i*4+h;u===4||h===4||f++;const x=r-d(f,1,1),j=r<d(f,3,1)?0:E(f)?1:2,M=Math.floor(((x+j)*12+373)/367),O=r-d(f,M,1)+1;return[f,M,O]}function H(n){return c(n*7+1,19)<7}function g(n){return H(n)?13:12}function l(n){const r=Math.floor((235*n-234)/19),t=12084+13753*r;let e=r*29+Math.floor(t/25920);return c(3*(e+1),7)<3&&e++,e}function q(n){const r=l(n-1),t=l(n);return l(n+1)-t===356?2:t-r===382?1:0}function w(n){return m(n+1,7,1)-m(n,7,1)}function a(n,r){return r===2||r===4||r===6||r===10||r===13||r===12&&!H(n)||r===8&&c(w(n),10)!==5||r===9&&c(w(n),10)===3?29:30}function m(n,r,t){let e;const o=g(n);let u=R+l(n)+q(n)+t+1;if(r<7){for(e=7;e<=o;e++)u+=a(n,e);for(e=1;e<r;e++)u+=a(n,e)}else for(e=7;e<r;e++)u+=a(n,e);return u}function D(n){let t,e;const o=Math.floor(n)+.5,u=Math.floor((o-347995.5)*98496/35975351);t=u-1;for(let b=u;o>=m(b,7,1);b++)t++;const s=o<m(t,1,1)?7:1;e=s;for(let b=s;o>m(t,b,a(t,b));b++)e++;const i=o-m(t,e,1)+1;return[t,e,i]}export{d as gregorianToJd,a as hebrewMonthDays,m as hebrewToJd,C as jdToGregorian,D as jdToHebrew,c as mod};
2
2
  //# sourceMappingURL=dateConverterUtils.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/dateUtils/dateConverterUtils.ts"],
4
- "sourcesContent": ["/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nconst GREGORIAN_EPOCH = 1721425.5;\n\nconst HEBREW_EPOCH = 347995.5;\n\n/**\n * Computes the remainder of the division of `a` by `b`.\n * Unlike the built-in JavaScript `%` operator, this function handles negative numbers properly.\n * For example, `mod(-1, 5)` returns `4`, not `-1`.\n * @param {number} a - The number to compute the remainder of.\n * @param {number} b - The divisor.\n * @returns {number} - The remainder of `a` divided by `b`.\n */\nexport function mod(a: number, b: number) {\n return a - b * Math.floor(a / b);\n}\n\n/**\n * Determines if a given year is a leap year in the Gregorian calendar.\n * @param year The year to check.\n * @returns True if the year is a leap year, false otherwise.\n */\nfunction leapGregorian(year: number) {\n return year % 4 === 0 && !(year % 100 === 0 && year % 400 !== 0);\n}\n\n/**\n * Converts Gregorian date to Julian Day.\n * @param {number} year - The year in the Gregorian calendar.\n * @param {number} month - The month in the Gregorian calendar (January = 1).\n * @param {number} day - The day of the month in the Gregorian calendar.\n * @returns {number} The Julian Day corresponding to the Gregorian date.\n */\nexport function gregorianToJd(\n year: number,\n month: number,\n day: number,\n): number {\n return (\n GREGORIAN_EPOCH -\n 1 +\n 365 * (year - 1) +\n Math.floor((year - 1) / 4) +\n -Math.floor((year - 1) / 100) +\n Math.floor((year - 1) / 400) +\n Math.floor(\n (367 * month - 362) / 12 +\n (month <= 2 ? 0 : leapGregorian(year) ? -1 : -2) +\n day,\n )\n );\n}\n\n/**\n * Converts a Julian day number to Gregorian date.\n * @param {number} jd - The Julian day number to convert.\n * @returns {[number, number, number]} The Gregorian date as a tuple in the form of [year, month, day].\n */\nexport function jdToGregorian(jd: number): [number, number, number] {\n const wjd: number = Math.floor(jd - 0.5) + 0.5;\n const depoch: number = wjd - GREGORIAN_EPOCH;\n const quadricent: number = Math.floor(depoch / 146097);\n const dqc: number = mod(depoch, 146097);\n const cent: number = Math.floor(dqc / 36524);\n const dcent: number = mod(dqc, 36524);\n const quad: number = Math.floor(dcent / 1461);\n const dquad: number = mod(dcent, 1461);\n const yindex: number = Math.floor(dquad / 365);\n let year: number = quadricent * 400 + cent * 100 + quad * 4 + yindex;\n if (!(cent === 4 || yindex === 4)) {\n year++;\n }\n const yearday: number = wjd - gregorianToJd(year, 1, 1);\n const leapadj: number =\n wjd < gregorianToJd(year, 3, 1) ? 0 : leapGregorian(year) ? 1 : 2;\n const month: number = Math.floor(((yearday + leapadj) * 12 + 373) / 367);\n const day: number = wjd - gregorianToJd(year, month, 1) + 1;\n\n return [year, month, day];\n}\n\n/**\n * Determines if a Hebrew year is a leap year.\n * A leap year occurs 7 times in a 19 year cycle.\n * @param year - the Hebrew year to check\n * @returns true if the year is a leap year, false otherwise\n */\nfunction hebrewLeap(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n/**\n * Returns the number of months in a Hebrew year\n * @param {number} year - The Hebrew year\n * @returns {number} The number of months in the Hebrew year (12 or 13)\n */\nfunction hebrewYearMonths(year: number) {\n return hebrewLeap(year) ? 13 : 12;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year, taking into account the \"dechiya\" (postponement) rules\n * specified in the Mishnah, which state that the start of the year can't be Sunday, Wednesday, or Friday.\n * @param {number} year - The Hebrew year for which to calculate the delay.\n * @returns {number} The day of the molad (the moment of the astronomical new moon) for the specified Hebrew year.\n */\nfunction calculateHebrewYearStartDelay(year: number) {\n const months = Math.floor((235 * year - 234) / 19);\n const parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day++;\n }\n return day;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year due to the length of adjacent years,\n * taking into account the \"dechiya\" (postponement) rules specified in the Mishnah.\n * The rules state that if the length of the year that is next in the 19-year cycle\n * (i.e., in the year after the current year) is exactly 356 days, then the start of the current year\n * is delayed by two days. Similarly, if the length of the year that immediately precedes the current year\n * is 382 days, then the start of the current year is delayed by one day. Otherwise, there is no delay.\n *\n * @param year - The Hebrew year for which to calculate the delay.\n * @returns The delay in days of the start of the Hebrew year.\n */\nfunction calculateHebrewYearAdjacentDelay(year: number) {\n const last = calculateHebrewYearStartDelay(year - 1);\n const present = calculateHebrewYearStartDelay(year);\n const next = calculateHebrewYearStartDelay(year + 1);\n\n return next - present === 356 ? 2 : present - last === 382 ? 1 : 0;\n}\n\n/**\n * Calculates the number of days in a Hebrew year.\n * @param {number} year - The Hebrew year to calculate.\n * @returns {number} - The number of days in the Hebrew year.\n */\nfunction hebrewYearDays(year: number) {\n return hebrewToJd(year + 1, 7, 1) - hebrewToJd(year, 7, 1);\n}\n\n/**\n * Calculates the number of days in the specified month of the Hebrew year.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The month of the year, where Nisan is 1 and Adar II (in leap years) is 13.\n * @returns {number} - The number of days in the specified month.\n */\nfunction hebrewMonthDays(year: number, month: number) {\n if (\n month === 2 ||\n month === 4 ||\n month === 6 ||\n month === 10 ||\n month === 13\n ) {\n return 29;\n }\n\n if (month === 12 && !hebrewLeap(year)) {\n return 29;\n }\n\n if (month === 8 && !(mod(hebrewYearDays(year), 10) === 5)) {\n return 29;\n }\n\n if (month === 9 && mod(hebrewYearDays(year), 10) === 3) {\n return 29;\n }\n\n return 30;\n}\n\n/**\n * Converts a Hebrew date to the corresponding Julian day.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The Hebrew month (1-13).\n * @param {number} day - The day of the month.\n * @returns {number} The Julian day corresponding to the Hebrew date.\n */\nexport function hebrewToJd(year: number, month: number, day: number) {\n let mon: number;\n\n const months = hebrewYearMonths(year);\n let jd =\n HEBREW_EPOCH +\n calculateHebrewYearStartDelay(year) +\n calculateHebrewYearAdjacentDelay(year) +\n day +\n 1;\n\n if (month < 7) {\n for (mon = 7; mon <= months; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n for (mon = 1; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n } else {\n for (mon = 7; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n }\n\n return jd;\n}\n\n/**\n * Converts a Julian date to a Hebrew date.\n * @param jd - The Julian date to convert.\n * @returns The Hebrew date as a tuple in the form of [year, month, day].\n */\nexport function jdToHebrew(julianDate: number): [number, number, number] {\n const HEBREW_EPOCH = 347995.5;\n let year: number;\n let month: number;\n\n const jd = Math.floor(julianDate) + 0.5;\n const count: number = Math.floor(\n ((jd - HEBREW_EPOCH) * 98496.0) / 35975351.0,\n );\n year = count - 1;\n for (let i = count; jd >= hebrewToJd(i, 7, 1); i++) {\n year++;\n }\n const first: number = jd < hebrewToJd(year, 1, 1) ? 7 : 1;\n month = first;\n for (let i = first; jd > hebrewToJd(year, i, hebrewMonthDays(year, i)); i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,CAAI,EACpC,IAAIK,EACFV,EACAwB,EAA8BnB,CAAI,EAClCsB,EAAiCtB,CAAI,EACrCG,EACA,EAEF,GAAID,EAAQ,EAAG,CACb,IAAK0B,EAAM,EAAGA,GAAOR,EAAQQ,IAC3BvB,GAAMsB,EAAgB3B,EAAM4B,CAAG,EAEjC,IAAKA,EAAM,EAAGA,EAAM1B,EAAO0B,IACzBvB,GAAMsB,EAAgB3B,EAAM4B,CAAG,CAEnC,KACE,KAAKA,EAAM,EAAGA,EAAM1B,EAAO0B,IACzBvB,GAAMsB,EAAgB3B,EAAM4B,CAAG,EAInC,OAAOvB,CACT,CAOO,SAASwB,EAAWC,EAA8C,CAEvE,IAAI9B,EACAE,EAEJ,MAAMG,EAAK,KAAK,MAAMyB,CAAU,EAAI,GAC9BC,EAAgB,KAAK,OACvB1B,EAAK,UAAgB,MAAW,QACpC,EACAL,EAAO+B,EAAQ,EACf,QAASC,EAAID,EAAO1B,GAAMqB,EAAWM,EAAG,EAAG,CAAC,EAAGA,IAC7ChC,IAEF,MAAMiC,EAAgB5B,EAAKqB,EAAW1B,EAAM,EAAG,CAAC,EAAI,EAAI,EACxDE,EAAQ+B,EACR,QAASD,EAAIC,EAAO5B,EAAKqB,EAAW1B,EAAMgC,EAAGL,EAAgB3B,EAAMgC,CAAC,CAAC,EAAGA,IACtE9B,IAEF,MAAMC,EAAME,EAAKqB,EAAW1B,EAAME,EAAO,CAAC,EAAI,EAC9C,MAAO,CAACF,EAAME,EAAOC,CAAG,CAC1B",
4
+ "sourcesContent": ["/**\n * Copyright (c) Shmulik Kravitz.\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory for more information.\n *\n */\n\nconst GREGORIAN_EPOCH = 1721425.5;\n\nconst HEBREW_EPOCH = 347995.5;\n\n/**\n * Computes the remainder of the division of `a` by `b`.\n * Unlike the built-in JavaScript `%` operator, this function handles negative numbers properly.\n * For example, `mod(-1, 5)` returns `4`, not `-1`.\n * @param {number} a - The number to compute the remainder of.\n * @param {number} b - The divisor.\n * @returns {number} - The remainder of `a` divided by `b`.\n */\nexport function mod(a: number, b: number) {\n return a - b * Math.floor(a / b);\n}\n\n/**\n * Determines if a given year is a leap year in the Gregorian calendar.\n * @param year The year to check.\n * @returns True if the year is a leap year, false otherwise.\n */\nfunction leapGregorian(year: number) {\n return year % 4 === 0 && !(year % 100 === 0 && year % 400 !== 0);\n}\n\n/**\n * Converts Gregorian date to Julian Day.\n * @param {number} year - The year in the Gregorian calendar.\n * @param {number} month - The month in the Gregorian calendar (January = 1).\n * @param {number} day - The day of the month in the Gregorian calendar.\n * @returns {number} The Julian Day corresponding to the Gregorian date.\n */\nexport function gregorianToJd(\n year: number,\n month: number,\n day: number,\n): number {\n return (\n GREGORIAN_EPOCH -\n 1 +\n 365 * (year - 1) +\n Math.floor((year - 1) / 4) +\n -Math.floor((year - 1) / 100) +\n Math.floor((year - 1) / 400) +\n Math.floor(\n (367 * month - 362) / 12 +\n (month <= 2 ? 0 : leapGregorian(year) ? -1 : -2) +\n day,\n )\n );\n}\n\n/**\n * Converts a Julian day number to Gregorian date.\n * @param {number} jd - The Julian day number to convert.\n * @returns {[number, number, number]} The Gregorian date as a tuple in the form of [year, month, day].\n */\nexport function jdToGregorian(jd: number): [number, number, number] {\n const wjd: number = Math.floor(jd - 0.5) + 0.5;\n const depoch: number = wjd - GREGORIAN_EPOCH;\n const quadricent: number = Math.floor(depoch / 146097);\n const dqc: number = mod(depoch, 146097);\n const cent: number = Math.floor(dqc / 36524);\n const dcent: number = mod(dqc, 36524);\n const quad: number = Math.floor(dcent / 1461);\n const dquad: number = mod(dcent, 1461);\n const yindex: number = Math.floor(dquad / 365);\n let year: number = quadricent * 400 + cent * 100 + quad * 4 + yindex;\n if (!(cent === 4 || yindex === 4)) {\n year++;\n }\n const yearday: number = wjd - gregorianToJd(year, 1, 1);\n const leapadj: number =\n wjd < gregorianToJd(year, 3, 1) ? 0 : leapGregorian(year) ? 1 : 2;\n const month: number = Math.floor(((yearday + leapadj) * 12 + 373) / 367);\n const day: number = wjd - gregorianToJd(year, month, 1) + 1;\n\n return [year, month, day];\n}\n\n/**\n * Determines if a Hebrew year is a leap year.\n * A leap year occurs 7 times in a 19 year cycle.\n * @param year - the Hebrew year to check\n * @returns true if the year is a leap year, false otherwise\n */\nfunction hebrewLeap(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n/**\n * Returns the number of months in a Hebrew year\n * @param {number} year - The Hebrew year\n * @returns {number} The number of months in the Hebrew year (12 or 13)\n */\nfunction hebrewYearMonths(year: number) {\n return hebrewLeap(year) ? 13 : 12;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year, taking into account the \"dechiya\" (postponement) rules\n * specified in the Mishnah, which state that the start of the year can't be Sunday, Wednesday, or Friday.\n * @param {number} year - The Hebrew year for which to calculate the delay.\n * @returns {number} The day of the molad (the moment of the astronomical new moon) for the specified Hebrew year.\n */\nfunction calculateHebrewYearStartDelay(year: number) {\n const months = Math.floor((235 * year - 234) / 19);\n const parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day++;\n }\n return day;\n}\n\n/**\n * Calculates the delay of the start of the Hebrew year due to the length of adjacent years,\n * taking into account the \"dechiya\" (postponement) rules specified in the Mishnah.\n * The rules state that if the length of the year that is next in the 19-year cycle\n * (i.e., in the year after the current year) is exactly 356 days, then the start of the current year\n * is delayed by two days. Similarly, if the length of the year that immediately precedes the current year\n * is 382 days, then the start of the current year is delayed by one day. Otherwise, there is no delay.\n *\n * @param year - The Hebrew year for which to calculate the delay.\n * @returns The delay in days of the start of the Hebrew year.\n */\nfunction calculateHebrewYearAdjacentDelay(year: number) {\n const last = calculateHebrewYearStartDelay(year - 1);\n const present = calculateHebrewYearStartDelay(year);\n const next = calculateHebrewYearStartDelay(year + 1);\n\n return next - present === 356 ? 2 : present - last === 382 ? 1 : 0;\n}\n\n/**\n * Calculates the number of days in a Hebrew year.\n * @param {number} year - The Hebrew year to calculate.\n * @returns {number} - The number of days in the Hebrew year.\n */\nfunction hebrewYearDays(year: number) {\n return hebrewToJd(year + 1, 7, 1) - hebrewToJd(year, 7, 1);\n}\n\n/**\n * Calculates the number of days in the specified month of the Hebrew year.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The month of the year, where Nisan is 1 and Adar II (in leap years) is 13.\n * @returns {number} - The number of days in the specified month.\n */\nexport function hebrewMonthDays(year: number, month: number) {\n if (\n month === 2 ||\n month === 4 ||\n month === 6 ||\n month === 10 ||\n month === 13\n ) {\n return 29;\n }\n\n if (month === 12 && !hebrewLeap(year)) {\n return 29;\n }\n\n if (month === 8 && !(mod(hebrewYearDays(year), 10) === 5)) {\n return 29;\n }\n\n if (month === 9 && mod(hebrewYearDays(year), 10) === 3) {\n return 29;\n }\n\n return 30;\n}\n\n/**\n * Converts a Hebrew date to the corresponding Julian day.\n * @param {number} year - The Hebrew year.\n * @param {number} month - The Hebrew month (1-13).\n * @param {number} day - The day of the month.\n * @returns {number} The Julian day corresponding to the Hebrew date.\n */\nexport function hebrewToJd(year: number, month: number, day: number) {\n let mon: number;\n\n const months = hebrewYearMonths(year);\n let jd =\n HEBREW_EPOCH +\n calculateHebrewYearStartDelay(year) +\n calculateHebrewYearAdjacentDelay(year) +\n day +\n 1;\n\n if (month < 7) {\n for (mon = 7; mon <= months; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n for (mon = 1; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n } else {\n for (mon = 7; mon < month; mon++) {\n jd += hebrewMonthDays(year, mon);\n }\n }\n\n return jd;\n}\n\n/**\n * Converts a Julian date to a Hebrew date.\n * @param jd - The Julian date to convert.\n * @returns The Hebrew date as a tuple in the form of [year, month, day].\n */\nexport function jdToHebrew(julianDate: number): [number, number, number] {\n const HEBREW_EPOCH = 347995.5;\n let year: number;\n let month: number;\n\n const jd = Math.floor(julianDate) + 0.5;\n const count: number = Math.floor(\n ((jd - HEBREW_EPOCH) * 98496.0) / 35975351.0,\n );\n year = count - 1;\n for (let i = count; jd >= hebrewToJd(i, 7, 1); i++) {\n year++;\n }\n const first: number = jd < hebrewToJd(year, 1, 1) ? 7 : 1;\n month = first;\n for (let i = first; jd > hebrewToJd(year, i, hebrewMonthDays(year, i)); i++) {\n month++;\n }\n const day = jd - hebrewToJd(year, month, 1) + 1;\n return [year, month, day];\n}\n"],
5
+ "mappings": "AAQA,MAAMA,EAAkB,YAElBC,EAAe,SAUd,SAASC,EAAIC,EAAWC,EAAW,CACxC,OAAOD,EAAIC,EAAI,KAAK,MAAMD,EAAIC,CAAC,CACjC,CAOA,SAASC,EAAcC,EAAc,CACnC,OAAOA,EAAO,IAAM,GAAK,EAAEA,EAAO,MAAQ,GAAKA,EAAO,MAAQ,EAChE,CASO,SAASC,EACdD,EACAE,EACAC,EACQ,CACR,OACET,EACA,EACA,KAAOM,EAAO,GACd,KAAK,OAAOA,EAAO,GAAK,CAAC,EACzB,CAAC,KAAK,OAAOA,EAAO,GAAK,GAAG,EAC5B,KAAK,OAAOA,EAAO,GAAK,GAAG,EAC3B,KAAK,OACF,IAAME,EAAQ,KAAO,IACnBA,GAAS,EAAI,EAAIH,EAAcC,CAAI,EAAI,GAAK,IAC7CG,CACJ,CAEJ,CAOO,SAASC,EAAcC,EAAsC,CAClE,MAAMC,EAAc,KAAK,MAAMD,EAAK,EAAG,EAAI,GACrCE,EAAiBD,EAAMZ,EACvBc,EAAqB,KAAK,MAAMD,EAAS,MAAM,EAC/CE,EAAcb,EAAIW,EAAQ,MAAM,EAChCG,EAAe,KAAK,MAAMD,EAAM,KAAK,EACrCE,EAAgBf,EAAIa,EAAK,KAAK,EAC9BG,EAAe,KAAK,MAAMD,EAAQ,IAAI,EACtCE,EAAgBjB,EAAIe,EAAO,IAAI,EAC/BG,EAAiB,KAAK,MAAMD,EAAQ,GAAG,EAC7C,IAAIb,EAAeQ,EAAa,IAAME,EAAO,IAAME,EAAO,EAAIE,EACxDJ,IAAS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d", "depoch", "quadricent", "dqc", "cent", "dcent", "quad", "dquad", "yindex", "yearday", "leapadj", "hebrewLeap", "hebrewYearMonths", "calculateHebrewYearStartDelay", "months", "parts", "calculateHebrewYearAdjacentDelay", "last", "present", "hebrewYearDays", "hebrewToJd", "hebrewMonthDays", "mon", "jdToHebrew", "julianDate", "count", "i", "first"]
7
7
  }
@@ -49,3 +49,10 @@ export declare const toJewishDate: (date: Date) => JewishDate;
49
49
  * @returns {Date} The Gregorian date corresponding to the given Jewish date.
50
50
  * */
51
51
  export declare const toGregorianDate: (jewishDate: BasicJewishDate) => Date;
52
+ /**
53
+ * Calculates the number of days in a Jewish month for a given Jewish year.
54
+ * @param {number} jewishYear - The Jewish year for which the calculation is performed.
55
+ * @param {JewishMonthType} jewishMonth - The type of Jewish month (e.g., 'Heshvan', 'Kislev').
56
+ * @returns {number} - The number of days in the specified Jewish month of the given year.
57
+ */
58
+ export declare const calcDaysInMonth: (jewishYear: number, jewishMonth: JewishMonthType) => number;
@@ -28,6 +28,13 @@ export declare function gregorianToJd(year: number, month: number, day: number):
28
28
  * @returns {[number, number, number]} The Gregorian date as a tuple in the form of [year, month, day].
29
29
  */
30
30
  export declare function jdToGregorian(jd: number): [number, number, number];
31
+ /**
32
+ * Calculates the number of days in the specified month of the Hebrew year.
33
+ * @param {number} year - The Hebrew year.
34
+ * @param {number} month - The month of the year, where Nisan is 1 and Adar II (in leap years) is 13.
35
+ * @returns {number} - The number of days in the specified month.
36
+ */
37
+ export declare function hebrewMonthDays(year: number, month: number): 29 | 30;
31
38
  /**
32
39
  * Converts a Hebrew date to the corresponding Julian day.
33
40
  * @param {number} year - The Hebrew year.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jewish-date",
3
3
  "description": "Converts Gregorian dates to Hebrew dates and vice versa.",
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/mjs/index.js",
@@ -19,35 +19,35 @@
19
19
  "scripts": {
20
20
  "start": "esr ./config/start.ts",
21
21
  "build": "yarn lint && yarn clean && esr ./config/build.ts",
22
- "lint": "yarn rome format src && yarn rome check src",
22
+ "lint": "yarn biome check ./src",
23
23
  "clean": "rimraf dist",
24
- "test": "vitest --config ./config/vitest.config.ts --coverage",
24
+ "test": "vitest --config ./config/vitest/vitest.config.ts --coverage",
25
25
  "p": "yarn pack --out %s-%v.tgz",
26
26
  "inc-version": "yarn version patch",
27
27
  "get-version": "node -p \"require('./package.json').version\""
28
28
  },
29
29
  "devDependencies": {
30
- "@types/gematriya": "^2.0.2",
31
- "@types/node": "^16.18.38",
32
- "@types/react": "^18.2.14",
33
- "@types/react-dom": "^18.2.6",
34
- "@vitest/coverage-v8": "^0.33.0",
35
- "esbuild": "^0.18.11",
36
- "esbuild-node-externals": "^1.8.0",
30
+ "@biomejs/biome": "^1.4.0",
31
+ "@types/gematriya": "^2.0.5",
32
+ "@types/node": "^18.18.9",
33
+ "@types/react": "^18.2.37",
34
+ "@types/react-dom": "^18.2.15",
35
+ "@vitest/coverage-v8": "^0.34.6",
36
+ "esbuild": "^0.19.5",
37
+ "esbuild-node-externals": "^1.9.0",
37
38
  "esbuild-runner": "^2.2.2",
38
39
  "react": "^18.2.0",
39
40
  "react-dom": "^18.2.0",
40
- "rimraf": "^5.0.1",
41
- "rome": "^12.1.3",
42
- "tsc-prog": "^2.2.1",
43
- "typescript": "^5.1.6",
44
- "vite": "^4.4.1",
45
- "vitest": "^0.33.0"
41
+ "rimraf": "^5.0.5",
42
+ "tsc-prog": "^2.3.0",
43
+ "typescript": "^5.2.2",
44
+ "vite": "^4.5.0",
45
+ "vitest": "^0.34.6"
46
46
  },
47
47
  "dependencies": {
48
48
  "gematriya": "^2.0.0"
49
49
  },
50
- "packageManager": "yarn@3.6.1",
50
+ "packageManager": "yarn@3.6.4",
51
51
  "husky": {
52
52
  "hooks": {
53
53
  "pre-commit": "lint-staged"