@hebcal/core 4.2.0 → 4.3.0

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/README.md CHANGED
@@ -344,6 +344,7 @@ Represents a Hebrew date
344
344
  * [.monthFromName(monthName)](#HDate.monthFromName) ⇒ <code>number</code>
345
345
  * [.dayOnOrBefore(dayOfWeek, absdate)](#HDate.dayOnOrBefore) ⇒ <code>number</code>
346
346
  * [.isHDate(obj)](#HDate.isHDate) ⇒ <code>boolean</code>
347
+ * [.fromGematriyaString(str, currentThousands)](#HDate.fromGematriyaString) ⇒ [<code>HDate</code>](#HDate)
347
348
 
348
349
  <a name="new_HDate_new"></a>
349
350
 
@@ -815,6 +816,24 @@ Tests if the object is an instance of `HDate`
815
816
  | --- | --- |
816
817
  | obj | <code>any</code> |
817
818
 
819
+ <a name="HDate.fromGematriyaString"></a>
820
+
821
+ ### HDate.fromGematriyaString(str, currentThousands) ⇒ [<code>HDate</code>](#HDate)
822
+ Construct a new instance of `HDate` from a Gematriya-formatted string
823
+
824
+ **Kind**: static method of [<code>HDate</code>](#HDate)
825
+
826
+ | Param | Type | Default |
827
+ | --- | --- | --- |
828
+ | str | <code>string</code> | |
829
+ | currentThousands | <code>number</code> | <code>5000</code> |
830
+
831
+ **Example**
832
+ ```js
833
+ HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
834
+ HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
835
+ HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
836
+ ```
818
837
  <a name="Event"></a>
819
838
 
820
839
  ## Event
package/dist/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.2.0 */
1
+ /*! @hebcal/core v4.3.0 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1690,6 +1690,12 @@ function gematriya(number) {
1690
1690
  */
1691
1691
  function gematriyaStrToNum(str) {
1692
1692
  var num = 0;
1693
+ var gereshIdx = str.indexOf(GERESH);
1694
+ if (gereshIdx !== -1 && gereshIdx !== str.length - 1) {
1695
+ var thousands = str.substring(0, gereshIdx);
1696
+ num += gematriyaStrToNum(thousands) * 1000;
1697
+ str = str.substring(gereshIdx);
1698
+ }
1693
1699
  for (var i = 0; i < str.length; i++) {
1694
1700
  var n = heb2num[str[i]];
1695
1701
  if (typeof n === 'number') {
@@ -3220,6 +3226,7 @@ var HDate = /*#__PURE__*/function () {
3220
3226
  return monthName;
3221
3227
  }
3222
3228
  var c = Locale.hebrewStripNikkud(monthName).trim().toLowerCase();
3229
+ // If Hebrew month starts with a bet (for example `בתמוז`) then ignore it
3223
3230
  if (c[0] === 'ב') {
3224
3231
  c = c.substring(1);
3225
3232
  }
@@ -3351,6 +3358,30 @@ var HDate = /*#__PURE__*/function () {
3351
3358
  value: function isHDate(obj) {
3352
3359
  return obj !== null && _typeof(obj) === 'object' && typeof obj.year === 'number' && typeof obj.month === 'number' && typeof obj.day === 'number' && typeof obj.greg === 'function' && typeof obj.abs === 'function';
3353
3360
  }
3361
+
3362
+ /**
3363
+ * Construct a new instance of `HDate` from a Gematriya-formatted string
3364
+ * @example
3365
+ * HDate.fromGematriyaString('כ״ז בְּתַמּוּז תשפ״ג') // 27 Tamuz 5783
3366
+ * HDate.fromGematriyaString('כ׳ סיון תש״ד') // 20 Sivan 5704
3367
+ * HDate.fromGematriyaString('ה׳ אִיָיר תש״ח') // 5 Iyyar 5708
3368
+ * @param {string} str
3369
+ * @param {number} currentThousands
3370
+ * @return {HDate}
3371
+ */
3372
+ }, {
3373
+ key: "fromGematriyaString",
3374
+ value: function fromGematriyaString(str) {
3375
+ var currentThousands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
3376
+ var parts = str.split(' ');
3377
+ var day = gematriyaStrToNum(parts[0]);
3378
+ var month = HDate.monthFromName(parts[1]);
3379
+ var year = gematriyaStrToNum(parts[2]);
3380
+ if (year < 1000) {
3381
+ year += currentThousands;
3382
+ }
3383
+ return new HDate(day, month, year);
3384
+ }
3354
3385
  }]);
3355
3386
  return HDate;
3356
3387
  }();
@@ -7552,7 +7583,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
7552
7583
  return new HDate(day, month, hyear);
7553
7584
  }
7554
7585
 
7555
- var version="4.2.0";
7586
+ var version="4.3.0";
7556
7587
 
7557
7588
  var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};var contexts$1={"":{Shabbat:["Shabbos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
7558
7589