hebcal / hebcal-es6

perpetual Jewish Calendar with holidays, Shabbat and holiday candle lighting and havdalah times, Torah readings, and more
https://hebcal.github.io/api/core/
GNU General Public License v2.0
100 stars 14 forks source link

Error Method get Intl.DateTimeFormat.prototype.format called on incompatible receiver undefined, with Devexpress datagrid #395

Closed aepshtin closed 7 months ago

aepshtin commented 7 months ago

Devepxress is very poplular datagrid system for Angular, React etc Since hebcal >=5.0, there is an error TypeError: Method get Intl.DateTimeFormat.prototype.format called on incompatible receiver undefined after initlize hebcal

This is the error in the devtools console: main.ts:11 ERROR TypeError: Method get Intl.DateTimeFormat.prototype.format called on incompatible receiver undefined at get format () at format (index.mjs:2029:55285) at formatDateTime (date.js:41:12) at date.js:27:16 at Object.format (date.js:207:20) at Object. (class.js:18:27) at object. [as format] (dependency_injector.js:29:46) at Object.format (format_helper.js:41:20) at object. [as format] (dependency_injector.js:29:46) at Object.formatValue (m_utils.js:121:21)

Below a link for very minimal example to see the error. How to install the example: 1) git clone https://github.com/aepshtin/test-hebcal-dx 2) cd test-hebcal-dx 3) npm i 4) ng s

then open the browser at: http://localhost:4200/

and see the error in the console Just comment out the Zman initilze and see how it works well

image

In version 4.5.1 it works well. But i want to use version >=5.0 becuse of the elevation calculation. Thanks a lot

aepshtin commented 7 months ago

In version 4.5.1 it works well. But i want to use version >=5.0 becuse of the elevation calculation. Thanks a lot

mjradwin commented 7 months ago

Thanks for the bug report.

We are having difficulty reproducing the error. Are you sure you have pushed your latest test example to GitHub?

Looking at the package.json file in https://github.com/aepshtin/test-hebcal-dx repo, we do not see any dependency on @hebcal/core.

Also, the following line of code does not appear anywhere in the test-hebcal-dx repo

let zman = new Zmanim(Location.lookup("Jerusalem"), new Date(), true);

Please double-check your test repo

aepshtin commented 7 months ago

I'm very sorry. I've pushed it now. Thanks

aepshtin commented 7 months ago

I've noticed that the error occurs even when I merely execute: "Location.lookup('Jerusalem');" or "Location.addLocation('test', new Location(31.7683, 35.2137, true, 'Asia/Jerusalem', 'test'))," without instantiating a new Zmanim object.

aepshtin commented 7 months ago

Or even just: new HDate();

mjradwin commented 7 months ago

A cursory examination of the error message you posted seems to point to the bundled Temporal polyfill. More investigation is needed to determine if there is pollution of global namespace for a format function.

mjradwin commented 7 months ago

It looks like there was a very recent release of the Temporal polyfill. We will try updating the dependency and rebuilding @hebcal/noaa and @hebcal/core packages to see if that fixes the issue

https://github.com/fullcalendar/temporal-polyfill/releases/tag/v0.2.1

mjradwin commented 7 months ago

This appears to be fixed in @hebcal/core version 5.2.2

You can also safely delete the dependency @hebcal/noaa from your package.json

aepshtin commented 7 months ago

Wow! You are a genius! Thank you!