panchang-ts 4.1.1 → 4.2.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 +73 -0
- package/dist/calendar/festivalsTable.cjs +25358 -0
- package/dist/calendar/festivalsTable.d.cts +39 -0
- package/dist/calendar/festivalsTable.d.ts +39 -0
- package/dist/calendar/festivalsTable.js +25353 -0
- package/dist/festivalsTableTypes-GePaspwd.d.cts +52 -0
- package/dist/festivalsTableTypes-GePaspwd.d.ts +52 -0
- package/dist/index.cjs +129 -7
- package/dist/index.d.cts +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +129 -8
- package/package.json +12 -1
package/README.md
CHANGED
|
@@ -262,6 +262,79 @@ getDailyPanchang(jan13, amritsar, { timezone: 330, region: 'punjab' })!
|
|
|
262
262
|
legacy slugs `'tamil'`, `'bengal'`, `'north-india'` are still accepted and
|
|
263
263
|
mapped internally.
|
|
264
264
|
|
|
265
|
+
### Pre-computed table (bundled, India / IST)
|
|
266
|
+
|
|
267
|
+
If you want festival *dates* without running the engine, import the static
|
|
268
|
+
table at `panchang-ts/festivals`. It bundles a rolling **2-years-past /
|
|
269
|
+
5-years-future** window pre-computed against Varanasi (IST). Within India
|
|
270
|
+
these dates are essentially universal.
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import {
|
|
274
|
+
getFestivalsForYear,
|
|
275
|
+
getFestivalsForDate,
|
|
276
|
+
FESTIVALS_META,
|
|
277
|
+
FESTIVALS_YEAR_RANGE,
|
|
278
|
+
} from 'panchang-ts/festivals';
|
|
279
|
+
|
|
280
|
+
const yr = FESTIVALS_YEAR_RANGE.start; // e.g. { start: 2024, end: 2031 }
|
|
281
|
+
getFestivalsForYear(yr)!.length; // ~150 festival days
|
|
282
|
+
const diwali = getFestivalsForYear(yr)!
|
|
283
|
+
.find(d => d.festivals.some(f => f.name === 'Diwali'))!.date;
|
|
284
|
+
getFestivalsForDate(diwali); // [Narak Chaturdashi, Diwali]
|
|
285
|
+
getFestivalsForDate(diwali, 'hi'); // [नरक चतुर्दशी, दिवाली]
|
|
286
|
+
FESTIVALS_META.referenceLocation; // "Varanasi"
|
|
287
|
+
FESTIVALS_META.languages; // ["en", "hi"]
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
This entry point is engine-free — it ships only the JSON + accessors, so
|
|
291
|
+
importing it won't pull the calculation engine into your bundle. Both `en`
|
|
292
|
+
and `hi` are bundled (names *and* descriptions); pass the locale as the
|
|
293
|
+
second argument. Eclipses are excluded (visibility is location-dependent —
|
|
294
|
+
use `getUpcomingEclipses`).
|
|
295
|
+
|
|
296
|
+
### Festivals outside India — build a location table and cache it
|
|
297
|
+
|
|
298
|
+
The bundled table is **IST-only**. Elsewhere (Europe, North America, rest
|
|
299
|
+
of world) festival dates can shift by ±1 day, because canonical times
|
|
300
|
+
(nishita / pradosha / chandrodaya …) are observer-dependent — and the shift
|
|
301
|
+
tracks the timezone offset, not the "region", so a single per-continent
|
|
302
|
+
table would mis-date boundary-day festivals.
|
|
303
|
+
|
|
304
|
+
For an offline app serving users worldwide, the right pattern is
|
|
305
|
+
**compute-once-then-cache for the user's actual location**. Build a
|
|
306
|
+
location-specific table with `buildFestivalsTable` (from the main entry —
|
|
307
|
+
it uses the engine), persist the returned JSON, then read it back through
|
|
308
|
+
the same accessors via their `source` argument:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
import { buildFestivalsTable } from 'panchang-ts';
|
|
312
|
+
import { getFestivalsForYear, getFestivalsForDate } from 'panchang-ts/festivals';
|
|
313
|
+
|
|
314
|
+
// On first use at the user's location (a few seconds on-device — run it in
|
|
315
|
+
// the background / chunk by year), then cache `table` to disk/MMKV.
|
|
316
|
+
const table = buildFestivalsTable({
|
|
317
|
+
location: { latitude: 40.7128, longitude: -74.006 },
|
|
318
|
+
timezoneOffsetMinutes: -300, // US Eastern (EST); 0 = UK, 330 = IST
|
|
319
|
+
startYear: 2024,
|
|
320
|
+
endYear: 2031,
|
|
321
|
+
languages: ['en'], // omit hi to halve the size
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// Later reads are instant lookups against the cached table:
|
|
325
|
+
getFestivalsForYear(2026, 'en', table);
|
|
326
|
+
getFestivalsForDate('2026-11-08', 'en', table); // key is in the table's tz
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
`buildFestivalsTable` returns the same `FestivalsFile` shape as the bundled
|
|
330
|
+
data, so a cached table and the bundled India table are interchangeable as
|
|
331
|
+
the `source` argument. India-majority apps can lean on the bundled table for
|
|
332
|
+
zero first-load latency and only compute-and-cache for non-IST users.
|
|
333
|
+
|
|
334
|
+
**Other notes:** Karva Chauth / Dhanteras / Diwali emit with Purnimanta
|
|
335
|
+
paksha naming. To regenerate the bundled India table after a registry
|
|
336
|
+
change, run `npm run festivals:gen` (rolling window, no constants to edit).
|
|
337
|
+
|
|
265
338
|
## Eclipses
|
|
266
339
|
|
|
267
340
|
```typescript
|