### Install @hebcal/core Source: https://github.com/hebcal/hebcal-es6/blob/main/README.md Install the @hebcal/core package using npm. ```bash npm install @hebcal/core ``` -------------------------------- ### Omer Day Brief Render Examples Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Omer.md Provides examples of the brief description output from renderBrief() for a specific day in English and Hebrew. ```string - English (day 8): "Today is 8 days, which are 1 week and 1 day of the Omer" ``` ```string - Hebrew (day 8): "הַיּוֹם שְׁמוֹנָה יָמִים שֶׁהֵם שָׁבוּעַ וְיוֹם אֶחָד בָּעוֹמֶר" ``` -------------------------------- ### Complete HebrewCalendar Configuration Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/configuration.md A comprehensive example demonstrating various configuration options for HebrewCalendar, including date range, event types, location, times, and daily learning. ```typescript import {HebrewCalendar, Location, flags} from '@hebcal/core'; const options = { // Date range year: 5784, isHebrewYear: true, numYears: 1, // Event types candlelighting: true, sedrot: true, omer: true, molad: true, yizkor: true, noMinorFast: false, noModern: false, noSpecialShabbat: false, // Location & times location: Location.lookup('Jerusalem'), candleLightingMins: 40, havdalahDeg: 8.5, useElevation: false, // Schedule il: true, // Israeli // Display locale: 'he', hour12: false, // Learning dailyLearning: { dafYomi: true, }, }; const events = HebrewCalendar.calendar(options); for (const ev of events) { console.log(ev.getDate().toString(), ev.render('he')); } ``` -------------------------------- ### Example: Get Full Location Name Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Demonstrates how to import the Location class and use `lookup` to find a location, then call `getName()` to retrieve its full descriptive name. ```typescript import {Location} from '@hebcal/core'; Location.lookup('San Francisco')?.getName(); // 'San Francisco, California, USA' ``` -------------------------------- ### Example: Rendering Event Descriptions in Different Locales Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Demonstrates how to use the render() method to get translated event descriptions in English, Hebrew, and Ashkenazi transliterations. Requires importing Event, HDate, and flags from '@hebcal/core'. ```typescript import {Event, HDate, flags} from '@hebcal/core'; const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG); ev.render('en'); // 'Shavuot' ev.render('he'); // 'שָׁבוּעוֹת' ev.render('ashkenazi'); // 'Shavuos' ``` -------------------------------- ### Configure Daily Learning Options Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/types.md Example of how to enable various daily study programs using the dailyLearning object. ```typescript dailyLearning: { dafYomi: true, // Enable Daf Yomi mishnaYomi: true, // Enable Mishna Yomi yerushalmi: 1, // Enable Yerushalmi (1=Vilna edition, 2=Schottenstein) nachYomi: true, // Enable Nach Yomi (Tanach) } ``` -------------------------------- ### HolidayEvent Constructor and Usage Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Demonstrates how to create a HolidayEvent instance for Passover (Pesach) and use its methods to get the full description, the base name, and a rendered version. ```typescript import {HolidayEvent, HDate, months, flags} from '@hebcal/core'; const pesach = new HolidayEvent( new HDate(15, months.NISAN, 5784), 'Pesach I', flags.CHAG, {cholHaMoedDay: undefined} ); console.log(pesach.getDesc()); // 'Pesach I' console.log(pesach.basename()); // 'Pesach' console.log(pesach.render('en')); // 'Pesach I' (with apostrophe handling) ``` -------------------------------- ### HolidayEvent getEmoji() Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Demonstrates how to get an emoji representation for different holiday categories using the getEmoji() method. Includes examples for regular holidays, special Shabbats, and custom emojis. ```typescript const pesach = new HolidayEvent(new HDate(15, 'Nisan', 5784), 'Pesach'); console.log(pesach.getEmoji()); // '✡️' const specialShabbat = new HolidayEvent( new HDate(7, 'Adar', 5784), 'Shabbat Zachor', flags.SPECIAL_SHABBAT ); console.log(specialShabbat.getEmoji()); // '🕍' // Custom emoji const custom = new HolidayEvent( new HDate(15, 'Nisan', 5784), 'Pesach', flags.CHAG, {emoji: '🍷'} ); console.log(custom.getEmoji()); // '🍷' ``` -------------------------------- ### Example: Get Short Location Name Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Shows how to use `getShortName()` to get a truncated city name. It illustrates the behavior for standard city names and those with 'DC' suffixes. ```typescript import {Location} from '@hebcal/core'; Location.lookup('San Francisco')?.getShortName(); // 'San Francisco' Location.lookup('Washington DC')?.getShortName(); // 'Washington, DC' ``` -------------------------------- ### AsaraBTevetEvent Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Shows an example of creating an AsaraBTevetEvent. This subclass handles special URL date formatting for events that might span two Gregorian years. ```typescript const asara = new AsaraBTevetEvent( new HDate(10, months.TEVET, 5784), 'Asara B''Tevet' ); // URL might be: https://www.hebcal.com/holidays/asara-b-tevet-20231228 ``` -------------------------------- ### Calculate Fast Start and End Times Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Determine the start (Alot HaShachar) and end (e.g., 3 stars) times for a fast day. This snippet illustrates calculating zmanim for specific astronomical angles relative to sunrise and sunset. ```typescript import {Location, Zmanim} from '@hebcal/core'; const jerusalem = Location.lookup('Jerusalem'); const fastDay = new Date(2023, 7, 9); // Tisha B'Av const zmanim = new Zmanim(jerusalem, fastDay, false); const fastStart = zmanim.sunriseOffset(16.1, false); // Alot HaShachar const fastEnd = zmanim.sunsetOffset(-7.083, false); // 3 medium-sized stars console.log(`Fast begins: ${Zmanim.formatTime(fastStart, jerusalem.getTimeFormatter())}`); console.log(`Fast ends: ${Zmanim.formatTime(fastEnd, jerusalem.getTimeFormatter())}`); ``` -------------------------------- ### HolidayEvent.url() Examples Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Illustrates the expected URL format for different holidays and years, including the Israel-only parameter. ```plaintext Pesach 2024 | https://www.hebcal.com/holidays/pesach-2024 Yom HaAtzma'ut 2024 (IL) | https://www.hebcal.com/holidays/yom-haatzma-ut-2024?i=on Yom Kippur 1900 | https://www.hebcal.com/holidays/yom-kippur-1900 ``` -------------------------------- ### Omer Day Render Examples Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Omer.md Illustrates the output of the render() method for different locales and specific Omer days, including a special case for day 1. ```string English (day 8 = 1 week 1 day): - "Omer 8: 1 week and 1 day within Gevurah" ``` ```string Hebrew (day 8): - "עוֹמֶר ח: שָׁבוּעַ וְיוֹם אֶחָד שֶׁבִּגְבוּרָה" ``` ```string Transliterated (day 8): - "Omer 8: 1 week and 1 day sheb'Gevurah" ``` ```string Special case (day 1): - English: "Omer 1: Lovingkindness within Lovingkindness" - Hebrew: "עוֹמֶר א: חֶֽסֶד שֶׁבְּחֶֽסֶד" ``` -------------------------------- ### HolidayEvent.basename() Examples Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Demonstrates the stripping rules applied by the basename() method to various holiday name inputs. ```plaintext "Erev Pesach" | "Pesach" "Pesach I" | "Pesach" "Pesach II" | "Pesach" "Sukkot III (CH''M)" | "Sukkot" "Chanukah: 5 Candles" | "Chanukah" "Rosh Hashana 5784" | "Rosh Hashana" "Hoshanot (Hoshana Raba)" | "Hoshanot" ``` -------------------------------- ### Omer Event Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Omer.md Demonstrates creating an OmerEvent for the 2nd day of the Omer (17 Nisan) and retrieving its description and full rendered output. ```typescript import {OmerEvent, HDate, months} from '@hebcal/core'; // 2nd day of Omer (17 Nisan) const omerDay2 = new OmerEvent(new HDate(17, months.NISAN, 5784), 2); console.log(omerDay2.getDesc()); // 'Omer 2' console.log(omerDay2.render('en')); // Full description with Sefira ``` -------------------------------- ### Build and Run Commands for Hebcal Source: https://github.com/hebcal/hebcal-es6/blob/main/CLAUDE.md Common npm scripts for building, testing, linting, and running the hebcal project. Ensure you have the project dependencies installed before running these commands. ```bash npm run build ``` ```bash npm test ``` ```bash npx vitest run test/somefile.spec.ts ``` ```bash npm run lint ``` ```bash npm run fix ``` ```bash npm run compile ``` ```bash npm run coverage ``` -------------------------------- ### Example: Format Sunset Time Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Demonstrates how to use Zmanim.formatTime to display the sunset time for a given location in a 24-hour format. Requires importing Location and Zmanim from '@hebcal/core'. ```typescript import {Location, Zmanim} from '@hebcal/core'; const loc = Location.lookup('New York'); const gloc = new Zmanim(loc, new Date(2023, 8, 8), false); const sunsetTime = gloc.sunset(); const timeStr = Zmanim.formatTime(sunsetTime, loc.getTimeFormatter()); console.log(timeStr); // '19:30' ``` -------------------------------- ### ChanukahEvent Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Illustrates the creation of a ChanukahEvent object, which includes candle count functionality. This is useful for representing Chanukah holidays. ```typescript const chanukah = new ChanukahEvent( new HDate(25, months.KISLEV, 5784), 'Chanukah: 1 Candles', flags.CHANUKAH_CANDLES ); ``` -------------------------------- ### Generating Holiday URLs Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md This TypeScript example iterates through calendar events and prints the URL for each HolidayEvent using the url() method, if available. ```typescript import {HolidayEvent} from '@hebcal/core'; const events = HebrewCalendar.calendar({ year: 2024, candlelighting: true, location: Location.lookup('New York'), }); for (const ev of events) { if (ev instanceof HolidayEvent) { const url = ev.url(); if (url) { console.log(`${ev.getDesc()}: ${url}`); } } } ``` -------------------------------- ### Render Brief Description of an Event Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Demonstrates how to get a brief, translated description of a regular Event. This method is often overridden by subclasses to provide shorter, specific outputs. ```typescript import {CandleLightingEvent} from '@hebcal/core'; // For a regular Event, renderBrief() == render() const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG); ev.renderBrief('en'); // 'Shavuot' ``` -------------------------------- ### Sedra Instance Caching Example Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Sedra.md Demonstrates that calling `getSedra` with identical arguments returns the same cached Sedra instance, confirming the caching mechanism. ```typescript import {getSedra, HDate} from '@hebcal/core'; const sedra1 = getSedra(5784, false); const sedra2 = getSedra(5784, false); console.log(sedra1 === sedra2); // true (same cached instance) ``` -------------------------------- ### Instantiate Molad Object Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Create a new Molad object by providing the Hebrew year and month. The months are 1-indexed starting with Nisan. ```typescript import {Molad, months} from '@hebcal/core'; const m = new Molad(5784, months.NISAN); console.log(m.getMonthName()); // 'Nisan' console.log(m.getHour(), m.getMinutes(), m.getChalakim()); // e.g. 1 31 12 console.log(m.render('en')); // 'Molad Nisan: Mon, 1:31am and 12 chalakim' ``` -------------------------------- ### Grouping Holiday Events by Basename Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md This TypeScript example shows how to use the basename() method to group holiday events from a calendar into a map, keyed by their simplified names. ```typescript import {HolidayEvent} from '@hebcal/core'; import {holidays} from '@hebcal/core'; // hypothetical const events = HebrewCalendar.calendar({ year: 5784, isHebrewYear: true, }); // Group events by basename const grouped = {}; for (const ev of events) { if (ev instanceof HolidayEvent) { const name = ev.basename(); if (!grouped[name]) grouped[name] = []; grouped[name].push(ev); } } for (const [name, evs] of Object.entries(grouped)) { console.log(`${name}: ${evs.length} events`); } ``` -------------------------------- ### Rendering Holiday Event Descriptions Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Use the render() and renderBrief() methods to get localized descriptions of HolidayEvents. The render() method also handles smart apostrophe formatting. ```typescript // Full translated description (with smart apostrophe handling) ev.render('en'); // 'Pesach I' ev.render('he'); // 'פסח א' // Brief description (same as render() for HolidayEvent) ev.renderBrief('en'); // 'Pesach I' ``` -------------------------------- ### Configure Calendar by Start and End Dates Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/configuration.md Define a specific date range for calendar generation using HebrewDate objects or standard JavaScript Date objects. ```typescript import {HDate, months} from '@hebcal/core'; // Pesach 5784 const start = new HDate(15, months.NISAN, 5784); const end = new HDate(22, months.NISAN, 5784); // 8 days diaspora HebrewCalendar.calendar({ start, end }); // Or with Gregorian dates HebrewCalendar.calendar({ start: new Date(2024, 3, 22), end: new Date(2024, 3, 30), }); ``` -------------------------------- ### Error Handling Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/INDEX.md Guide to error handling within the @hebcal/core library, detailing conditions for `TypeError` and `RangeError`, recommended error handling patterns, and safe operation practices. ```APIDOC ## Error Handling ### Description Guide to error handling, including common error types and best practices. ### Error Types - `TypeError`: Conditions for invalid arguments. - `RangeError`: Conditions for out-of-range values. ### Practices - Error handling patterns. - Safe operations (that don't throw errors). - Validation constraints. ``` -------------------------------- ### Import Specific Modules for Tree-Shaking Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/README.md Import only the necessary functions from specific @hebcal/core modules to optimize bundle size. This example shows importing getHolidaysOnDate from the holidays module, which avoids including Zmanim dependencies. ```typescript // Good: drops Zmanim dependencies if not used import {getHolidaysOnDate} from '@hebcal/core/dist/esm/holidays'; // Larger bundle: includes Zmanim and candles import {getHolidaysOnDate} from '@hebcal/core'; ``` -------------------------------- ### Get Hebrew Date from Event Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Retrieve the Hebrew date associated with an Event object. The returned HDate object can be further processed, for example, to convert it to a Gregorian date. ```typescript getDate(): HDate ``` -------------------------------- ### Enable Daily Learning Programs Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/configuration.md Configure the `dailyLearning` option to enable daily study programs like Daf Yomi, Mishna Yomi, Yerushalmi, and Nach Yomi. Requires the `@hebcal/learning` package. ```typescript HebrewCalendar.calendar({ year: 5784, isHebrewYear: true, dailyLearning: { dafYomi: true, mishnaYomi: true, yerushalmi: 1, // Vilna edition nachYomi: true, }, }); ``` -------------------------------- ### Basic CalOptions Configuration Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/configuration.md Configure calendar generation with year, location, and specific event types like candle lighting and sedrot. ```typescript const options: CalOptions = { year: 5784, isHebrewYear: true, candlelighting: true, location: Location.lookup('Jerusalem'), il: true, sedrot: true, omer: true, }; const events = HebrewCalendar.calendar(options); ``` -------------------------------- ### Configuration Options Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/INDEX.md Provides a reference for all `CalOptions` used to configure the calendar generation. This includes options for date ranges, event types, location-specific settings, and language preferences. ```APIDOC ## Configuration Options (`CalOptions`) ### Description Reference for all configuration options used to customize calendar generation. ### Options - **Date Range**: `year`, `month`, `numYears`, `start`, `end`. - **Event Toggles**: `holidays`, `sedrot`, `omer`, `molad`, etc. - **Time Calculations**: `candleLighting`, `havdalah` configuration. - **Location Settings**: Israel vs. Diaspora schedule selection. - **Localization**: `locale`, time format settings. - **Daily Learning**: Configuration for daily learning schedules. ``` -------------------------------- ### Get holidays for a Hebrew year as a sorted Array Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HebrewCalendar.md Use getHolidaysForYearArray to get a sorted array of holidays for a specific Hebrew year, pre-filtered for either the Israeli or Diaspora schedule. This method simplifies usage by ensuring all returned events match the specified schedule. ```typescript import {HebrewCalendar} from '@hebcal/core'; const events = HebrewCalendar.getHolidaysForYearArray(5784, false); console.log(events[0].getDesc()); // 'Rosh Hashana 5784' ``` -------------------------------- ### Create a Custom Location Instance Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Demonstrates how to instantiate the Location class with specific geographic coordinates, timezone, and descriptive information for a custom location. ```typescript import {Location} from '@hebcal/core'; // Create a custom location for Chicago const chicago = new Location( 41.85003, // latitude -87.65005, // longitude false, // Diaspora 'America/Chicago', // timezone 'Chicago, Illinois, USA', 'US' ); console.log(chicago.getIsrael()); // false console.log(chicago.getName()); // 'Chicago, Illinois, USA' console.log(chicago.getShortName()); // 'Chicago' ``` -------------------------------- ### ChanukahEvent Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/HolidayEvent.md Represents a Chanukah holiday and includes a method to get the current candle count. ```APIDOC ## ChanukahEvent ### Description Chanukah holiday with candle count. ### Method Signature ```typescript class ChanukahEvent extends HolidayEvent { getCandleCount(): number } ``` ### Example ```typescript const chanukah = new ChanukahEvent( new HDate(25, months.KISLEV, 5784), 'Chanukah: 1 Candles', flags.CHANUKAH_CANDLES ); ``` ``` -------------------------------- ### Event Constructor Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Initializes a new Event object with a Hebrew date, description, and optional flags and attributes. ```APIDOC ## Event Constructor ### Description Initializes a new Event object with a Hebrew date, description, and optional flags and attributes. ### Parameters #### Path Parameters - **date** (HDate) - Required - Hebrew date of event - **desc** (string) - Required - English description (not translated) - **mask** (number) - Optional - Bitmask of flags (defaults to 0) - **attrs** (object) - Optional - Additional attributes (emoji, memo, alarm, etc.) (defaults to {}) ### Properties - **date** (HDate) - Hebrew date of this event (readonly) - **desc** (string) - English description (readonly) - **mask** (number) - Bitmask of flags (readonly) - **emoji** (string | undefined) - Optional emoji character (✡️, 🕯️, 🌒, etc.) - **memo** (string | undefined) - Optional longer description or memo - **alarm** (Date | string | boolean | undefined) - Optional alarm for iCalendar feeds ### Example ```typescript import {Event, HDate, flags} from '@hebcal/core'; const ev = new Event( new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG, {emoji: '📜'} ); ev.getDate().toString(); // '6 Sivan 5749' ev.getDesc(); // 'Shavuot' ev.getFlags(); // 1 (CHAG flag) ev.render('he'); // 'שָׁבוּעוֹת' ``` ``` -------------------------------- ### Get Molad Object from MoladEvent Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Retrieves the Molad object associated with a MoladEvent instance. ```typescript getMolad(): Molad ``` -------------------------------- ### Get Longitude Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Retrieves the decimal longitude of the location. This method returns a number representing the longitude. ```typescript getLongitude(): number ``` -------------------------------- ### Instantiate Zmanim Class Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Create a new Zmanim instance with geographic location, date, and elevation settings. This is the primary step for performing zmanim calculations. ```typescript import {Location, Zmanim} from '@hebcal/core'; import {GeoLocation} from '@hebcal/noaa'; const gloc = new GeoLocation(null, 41.822232, -71.448292, 0, 'America/New_York'); const friday = new Date(2023, 8, 8); const zmanim = new Zmanim(gloc, friday, false); const candleLighting = zmanim.sunsetOffset(-18, true); ``` -------------------------------- ### Get Elevation Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Retrieves the elevation of the location above sea level in meters. Returns 0 if the elevation is not set. ```typescript getElevation(): number ``` -------------------------------- ### Zmanim Constructor Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Initializes a Zmanim object for a given geographic location, date, and elevation setting. The constructor uses algorithms from NOAA for accurate time estimations. ```APIDOC ## Zmanim Constructor ### Description Initializes a Zmanim object for a given geographic location, date, and elevation setting. The constructor uses algorithms from NOAA for accurate time estimations. ### Parameters #### Path Parameters - **gloc** (GeoLocation) - Yes - Geographic location (latitude, longitude, timezone) from @hebcal/noaa or a Location instance - **date** (Date | HDate) - Yes - Date for calculation (hours/minutes/seconds ignored) - **useElevation** (boolean) - Yes - Use elevation in calculations (if `true` and elevation > 0, affects sunrise/sunset) ### Example ```typescript import {Location, Zmanim} from '@hebcal/core'; import {GeoLocation} from '@hebcal/noaa'; const gloc = new GeoLocation(null, 41.822232, -71.448292, 0, 'America/New_York'); const friday = new Date(2023, 8, 8); const zmanim = new Zmanim(gloc, friday, false); const candleLighting = zmanim.sunsetOffset(-18, true); ``` ``` -------------------------------- ### Get Hour of Molad Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Retrieves the hour of the molad in a 24-hour format. Returns a number between 0 and 23. ```typescript getHour(): number ``` -------------------------------- ### Molad.render() Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Returns a translated string description of the molad, allowing for locale-specific rendering. ```APIDOC ## Molad.render() ### Description Returns a translated string description of the molad. ### Method ```typescript render(locale?: string): string ``` ### Parameters #### Parameters - **locale** (string) - Optional - Locale name (e.g., 'en', 'he', 'fr') ### Return Value `string` — Rendered molad description in the specified locale. ### Example Output - English: "Molad Nisan: Monday, 1:31am and 12 chalakim" - Hebrew: "מוֹלָד נִיסָן בַּיוֹם שֵׁנִי בַּשָּׁעָה אַחַת וּשְׁלוֹשִׁים וּשְׁנֵים חֲלָקִים" - French: "Molad Nisan: Lundi, 1:31 et 12 chaluqim" ``` -------------------------------- ### Get @hebcal/core Version (Imported) Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/utilities.md Access the semantic version of the @hebcal/core library directly after importing the version constant. ```typescript import {version} from '@hebcal/core'; console.log(`Using @hebcal/core ${version}`); ``` -------------------------------- ### Get Hebrew Year of Molad Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Retrieves the Hebrew year associated with the molad. Returns a number representing the year. ```typescript getYear(): number ``` -------------------------------- ### Get Untranslated Event Description Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Retrieves the English description of a Hebcal event. These descriptions are stable across releases. ```typescript getDesc(): string ``` -------------------------------- ### Event.renderBrief() Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Returns a brief translated description of the event. This method is useful for generating concise event summaries, often omitting time details. ```APIDOC ## Event.renderBrief() ### Description Returns a brief translated description of this event, often without time or extra qualifiers. ### Method Signature ```typescript renderBrief(locale?: string): string ``` ### Parameters #### Query Parameters - **locale** (string) - Optional - Locale name (defaults to empty locale) ### Return Value `string` — Brief translated description. ### Subclass Behavior - **CandleLightingEvent:** Returns "Candle lighting" - **HavdalahEvent:** Returns "Havdalah" (optionally with minute suffix) - **OmerEvent:** Returns count without "Today is..." - **Regular Event:** Returns same as `render()` ### Example ```typescript import {CandleLightingEvent} from '@hebcal/core'; const ev = new Event(new HDate(6, 'Sivan', 5749), 'Shavuot', flags.CHAG); ev.renderBrief('en'); // 'Shavuot' ``` ``` -------------------------------- ### Get Holidays for a Year Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/GUIDE.md Retrieve an array of all holidays for a specified Hebrew year. Iterates through the events to display date and name. ```typescript const events = HebrewCalendar.getHolidaysForYearArray(5784, false); for (const ev of events) { console.log(ev.getDate(), ev.render('en')); } ``` -------------------------------- ### Location Constructor Parameters Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Defines the parameters for creating a new Location object, including latitude, longitude, Israel/Diaspora status, timezone, and optional geographic details. ```typescript constructor( latitude: number, longitude: number, il: boolean, tzid: string, cityName?: string, countryCode?: string, geoid?: string | number, elevation?: number ) ``` -------------------------------- ### Get Timezone ID Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Retrieves the Olson timezone ID for the location. This is a string identifier for the timezone, such as "America/New_York". ```typescript getTimeZoneId(): string ``` -------------------------------- ### Get Day of Week of Molad Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Retrieves the day of the week for the molad. Days are numbered from 0 for Sunday to 6 for Saturday. ```typescript getDow(): number ``` -------------------------------- ### Instantiate and Render ParshaEvent Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Sedra.md Demonstrates creating a ParshaEvent object from Sedra results and rendering its name in English and Hebrew. Requires SedraResult, Sedra, and HDate imports. ```typescript import {ParshaEvent, Sedra, HDate} from '@hebcal/core'; const sedra = new Sedra(5784, false); const result = sedra.lookup(new HDate(23, 'Cheshvan', 5784)); const ev = new ParshaEvent(result); console.log(ev.render('en')); // 'Parashat Noach' console.log(ev.render('he')); // 'פרשת נח' ``` -------------------------------- ### Get Gregorian Date of Event Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Returns the Gregorian date for a Hebcal event. This method returns a JavaScript Date object. ```typescript greg(): Date ``` -------------------------------- ### Location.addLocation() Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Registers a new Location instance into the built-in database, making it available for lookup via `Location.lookup()`. ```APIDOC ## Location.addLocation() ### Description Static method to register a new Location in the built-in database for use with `Location.lookup()`. ### Method Signature `static addLocation(cityName: string, location: Location): void` ### Parameters #### Path Parameters - **cityName** (string) - Required - City name key for lookup - **location** (Location) - Required - Location instance to register ### Example ```typescript import {Location} from '@hebcal/core'; const myCity = new Location( 40.7128, -74.0060, false, 'America/New_York', 'New York City, New York, USA', 'US' ); Location.addLocation('New York', myCity); const found = Location.lookup('New York'); console.log(found?.getName()); // 'New York City, New York, USA' ``` ``` -------------------------------- ### Get Sunrise Time Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Retrieve the sunrise time for the specified location and date. The calculation includes elevation if enabled during Zmanim instantiation. ```typescript sunrise(): Date ``` -------------------------------- ### Type Definitions Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/COMPLETION_SUMMARY.txt The library defines several key types used for configuration and return values, including `CalOptions`, `SedraResult`, `HolidayYearMap`, and others, ensuring type safety and clarity. ```APIDOC ## Type Definitions ### Description @hebcal/core utilizes several type definitions to structure data and configuration, enhancing code clarity and enabling better static analysis. ### Types - **`CalOptions`**: Defines the structure for options used in calendar generation and other methods. - **`DailyLearningValue`**: Represents values related to daily learning cycles. - **`SedraResult`**: Describes the structure of the result returned by `getSedra`. - **`HolidayYearMap`**: A map structure for organizing holidays by year. - **`OmerLang`**: Specifies language options for Omer counting. - **`flags` enum**: An enumeration of flags used to categorize events and their properties. ``` -------------------------------- ### Get Minutes Past Hour of Molad Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Retrieves the number of minutes past the hour for the molad. Returns a number between 0 and 59. ```typescript getMinutes(): number ``` -------------------------------- ### Zmanim.sunrise() Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Calculates the sunrise time for the specified location and date. The calculation accounts for elevation if enabled during Zmanim object initialization. ```APIDOC ## Zmanim.sunrise() ### Description Upper edge of the sun appears over the eastern horizon (0.833° above horizon). ### Method ```typescript sunrise(): Date ``` ### Return Value `Date` — Sunrise time. If elevation is enabled, elevation is included in calculation. ``` -------------------------------- ### Generate a Hebrew Calendar Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/GUIDE.md Generate a full Hebrew calendar for a given year, including candle lighting, sedrot, and omer counts. Requires importing HebrewCalendar and Location. ```typescript import {HebrewCalendar, Location} from '@hebcal/core'; const events = HebrewCalendar.calendar({ year: 2024, candlelighting: true, location: Location.lookup('New York'), sedrot: true, omer: true, }); for (const ev of events) { console.log(ev.getDate().toString(), ev.render('en')); } ``` -------------------------------- ### Utilities Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/INDEX.md A collection of helper functions for various calendar-related tasks, including holiday utilities, halachic state checks, Torah reading lookups, time formatting, and version information. ```APIDOC ## Utilities ### Description Helper functions for common calendar-related tasks. ### Functions - **Holiday Utilities**: `getHolidaysOnDate()`, `getHolidaysForYear_()`. - **Halachic State**: `isAssurBemlacha()`, `isAveilut()`, `isFastDay()`. - **Torah Reading**: `getSedra()`, `parshiot`. - **Prayer Times**: `hallel_()`, `tachanun()`. - **Time Formatting**: `reformatTimeStr()`. - **Version Info**: Access to library version information. ``` -------------------------------- ### Get Sedra Data Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Sedra.md Retrieves the Torah reading schedule (sedra) for a specified Hebrew year. This is a foundational method for accessing parsha information. ```APIDOC ## getSedra ### Description Retrieves the Torah reading schedule (sedra) for a specified Hebrew year. ### Method Signature `getSedra(year: number, israel: boolean): Sedra` ### Parameters #### Path Parameters - **year** (number) - Required - The Hebrew year for which to retrieve the sedra. - **israel** (boolean) - Required - A boolean indicating whether to use the Israeli sedra schedule (true) or the diaspora schedule (false). ### Response - **Sedra** - An object representing the Torah reading schedule for the year. ``` -------------------------------- ### Calculate Candle-Lighting Times Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/configuration.md Configure candle-lighting and Havdalah calculations by setting the `candlelighting` option to true and providing a valid `location`. Custom minutes before sunset for candle lighting can be specified. ```typescript import {Location} from '@hebcal/core'; const loc = Location.lookup('Jerusalem'); HebrewCalendar.calendar({ year: 2024, candlelighting: true, location: loc, candleLightingMins: 40, // Jerusalem custom: 40 minutes }); ``` -------------------------------- ### Get Location Name Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md An alias for getName(), this method returns the full descriptive name of the location. It may return null if the name is not set. ```typescript getLocationName(): string | null ``` -------------------------------- ### Get Holiday Reading Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Sedra.md Retrieves the Torah reading name and Haftara reference for a specific Hebrew date. Returns null if the date does not have a specific reading. ```typescript getHolidayReading(hdate: HDate): string | null ``` -------------------------------- ### Instantiate Sedra and Lookup Parsha Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Sedra.md Instantiates the Sedra class for a specific Hebrew year and checks for the Torah reading on a given Hebrew date. Use the constructor directly only if caching is not a concern; prefer `getSedra()` for performance. ```typescript import {Sedra, HDate} from '@hebcal/core'; const sedra = new Sedra(5784, false); const result = sedra.lookup(new HDate(15, 'Cheshvan', 5784)); console.log(result.parsha); // ['Lech-Lecha'] ``` -------------------------------- ### Get Holidays for a Specific Date Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/GUIDE.md Retrieve holidays for a specific Hebrew date using HDate and HebrewCalendar.getHolidaysOnDate. Requires importing HebrewCalendar, HDate, and months. ```typescript import {HebrewCalendar, HDate, months} from '@hebcal/core'; const hd = new HDate(15, months.NISAN, 5784); // Pesach const holidays = HebrewCalendar.getHolidaysOnDate(hd, false); // Diaspora console.log(holidays?.map(h => h.getDesc())); // ['Pesach I'] ``` -------------------------------- ### Import Types from @hebcal/noaa Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/types.md Import geographic location and NOAA solar time calculator types from the @hebcal/noaa library. ```typescript import { GeoLocation, NOAACalculator, } from '@hebcal/noaa' ``` -------------------------------- ### Configure Hebcal Options Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/GUIDE.md Set various options for date range, events, location, and display preferences. Location is required for candlelighting. ```typescript const options = { // Date range year: 5784, isHebrewYear: true, month: months.NISAN, numYears: 1, start: new HDate(1, months.NISAN, 5784), end: new HDate(22, months.NISAN, 5784), // Events candlelighting: true, sedrot: true, omer: true, molad: true, yizkor: true, noMinorFast: false, noModern: false, // Location (required for candlelighting) location: Location.lookup('New York'), candleLightingMins: 18, havdalahDeg: 8.5, useElevation: false, // Schedule il: false, // Diaspora // Display locale: 'en', hour12: true, }; ``` -------------------------------- ### Get Location Latitude Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Retrieve the decimal latitude of the location using `getLatitude()`. This method returns a numeric value representing the location's latitude. ```typescript getLatitude(): number ``` -------------------------------- ### Configure Israeli vs. Diaspora Schedule Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/configuration.md Use the `il` option to select between Israeli and Diaspora holiday and Torah reading schedules. Set to `true` for Israel, `false` for Diaspora. ```typescript HebrewCalendar.calendar({ year: 5784, isHebrewYear: true, il: true, // Use Israeli holidays }); HebrewCalendar.calendar({ year: 5784, isHebrewYear: true, il: false, // Use Diaspora holidays (default) }); ``` -------------------------------- ### Get Full Location Name Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Location.md Retrieve the complete descriptive name of the location provided during its construction using `getName()`. Returns `null` if no name was specified. ```typescript getName(): string | null ``` -------------------------------- ### Get Molad Hebrew Date Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Molad.md Retrieve the specific Hebrew date when the molad occurs. This date often falls on the 28th or 30th of the preceding month. ```typescript getMoladDate(): HDate ``` -------------------------------- ### Get Event Flags Bitmask Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Event.md Returns a numerical bitmask representing the flags associated with a Hebcal event. This mask can be tested using bitwise AND operations. ```typescript getFlags(): number ``` -------------------------------- ### Display Omer Event in Different Languages Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Omer.md Demonstrates rendering a specific Omer event (Omer day 15) in English, Hebrew, and transliterated formats, as well as a brief English description. Requires importing HDate, OmerEvent, and months from @hebcal/core. ```typescript import {OmerEvent, HDate, months} from '@hebcal/core'; const omerDay15 = new OmerEvent(new HDate(30, months.NISAN, 5784), 15); console.log('English:', omerDay15.render('en')); // "Omer 15: 2 weeks and 1 day within Beauty" console.log('Hebrew:', omerDay15.render('he')); // "עוֹמֶר טו: שְׁנֵי שָׁבוּעוֹת וְיוֹם אֶחָד שֶׁבְּתִפְאֶֽרֶת" console.log('Transliterated:', omerDay15.render('translit')); // "Omer 15: 2 weeks and 1 day sheb'Tiferet" console.log('Brief (English):', omerDay15.renderBrief('en')); // "Today is 15 days, which are 2 weeks and 1 day of the Omer" ``` -------------------------------- ### OmerEvent.render() Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Omer.md Generates a comprehensive description of the Omer day, including the week count and Sefira attribute, with support for different locales. ```APIDOC ## OmerEvent.render() ### Description Returns a full description of the Omer day including week count and Sefira attribute. ### Method ```typescript render(locale?: string): string ``` ### Parameters #### Query Parameters - **locale** (string) - Optional - Locale name: `'en'` (default), `'he'`, `'translit'` ### Return Value `string` — Full description with Omer count and Sefira. ### Output Examples **English (day 8 = 1 week 1 day):** - `"Omer 8: 1 week and 1 day within Gevurah"` **Hebrew (day 8):** - `"עוֹמֶר ח: שָׁבוּעַ וְיוֹם אֶחָד שֶׁבִּגְבוּרָה"` **Transliterated (day 8):** - `"Omer 8: 1 week and 1 day sheb'Gevurah"` **Special case (day 1):** - English: `"Omer 1: Lovingkindness within Lovingkindness"` - Hebrew: `"עוֹמֶר א: חֶֽסֶד שֶׁבְּחֶֽסֶד"` ``` -------------------------------- ### Set and Get Elevation Adjustment Source: https://github.com/hebcal/hebcal-es6/blob/main/_autodocs/Zmanim.md Controls whether elevation adjustments are used for sunrise and sunset calculations. Elevation affects only sunrise/sunset-based zmanim, not angle-based calculations. ```typescript setUseElevation(useElevation: boolean): void ``` ```typescript getUseElevation(): boolean ```