0
Not a bug

how to get daily learning to work in calendar api calls

tobidogger 2 weeks ago updated by Michael J. Radwin 2 weeks ago 4

I cannot seen to get the dailyLearning to return anything in the HebrewCalendar.calendar call, what is the trick to making this work?

const options = {
    isHebrewYear: false,
    candlelighting: true,
    location: location,
    sedrot: true,
    omer: false,
    start: start,
    end: end,
    useElevation: true,
    hour12: false,
    dailyLearning: { DafYomi: true },
};

const events = HebrewCalendar.calendar(options)

This works partially; I get the info for the date rage I feed in but the data returned looks like...

{"date":{"mm":10,"dd":10,"yy":5785,"rd":739261},"desc":"Fast begins","mask":256,"eventTime":"2025-01-10T14:18:00.000Z","location":{"locationName":null,"latitude":48.8,"longitude":-122.5,"elevation":100,"timeZoneId":"America/Los_Angeles","il":false,"cc":"","geoid":""},"eventTimeStr":"06:18","fmtTime":"06:18","linkedEvent":{"date":{"mm":10,"dd":10,"yy":5785,"rd":739261},"desc":"Asara B'Tevet","mask":256}}

which is great :) but I am expecting the 

dailyLearning: { DafYomi: true}

to add in the daily reading in each date output. I cannot find example of people using this call this way in GITHUB or anywhere so something tells me it doesnt work or is not how this is intended. All it says is that the learning lib is used, which, sure, ok, that makes sense, but what it looks like is you have to take the date and put it through another set of calls to look up the learning iteratively. If this were the case, what is the purpose of adding in a dailyLearning option to the calendar? So I am missing something...

Answer

-1
Answer
Not a bug

Short answer: use

dafYomi: true

Note the camelCase.

Long answer: we need to improve our documentation.

The names of the dailyLearning calendars are published here in the Readme, but we need a few more code examples.

https://github.com/hebcal/hebcal-learning/blob/main/README.md

Here is the entire setup:

var hebcalCore = global.get("hebcalCore");
var hebcalLearning = global.get("hebcalLearning");

var Location = hebcalCore.Location;
var HebrewCalendar = hebcalCore.HebrewCalendar;
var Event = hebcalCore.Event;
var HDate = hebcalCore.HDate;
var HebrewDateEvent = hebcalCore.HebrewDateEvent;

var start = new Date();
var end = new Date(new Date().setDate(new Date().getDate() + 14));

const location = new Location(48.8, -122.5, false, "America/Los_Angeles",'','','',100);

msg.payload = {};

const options = {
    isHebrewYear: false,
    candlelighting: true,
    location: location,
    sedrot: true,
    omer: false,
    start: start,
    end: end,
    useElevation: true,
    hour12: false,
    dailyLearning: { dafYomi: true },
};

const events = HebrewCalendar.calendar(options);

I have a hunch that the import of learning is failing and the format isnt liked here...is there a normal name that the code expects or an instantiated name?

What module loader is global.get? I've never seen this before and don't really understand what that is doing, nor where the hebcalCore or hebcalLearning names are coming from (those particular camelCase names are NOT used by our code, so they must be yours?).

For a standard ES import, you'd use this:

import {HebrewCalendar, Location, Event, HDate} from '@hebcal/core';
import '@hebcal/learning';

Or using dynamic imports:

const {HebrewCalendar, Location, Event, HDate} = await import('@hebcal/core');
await import('@hebcal/learning');

I should have said that I tried that :) sorry

const options = {
    isHebrewYear: false,
    candlelighting: true,
    location: location,
    sedrot: true,
    omer: false,
    start: start,
    end: end,
    useElevation: true,
    hour12: false,
    dailyLearning: { dafYomi: true },
};

const events = HebrewCalendar.calendar(options);

also returns no daily readings...

but returns all the other information expected.

-1
Answer
Not a bug

Short answer: use

dafYomi: true

Note the camelCase.

Long answer: we need to improve our documentation.

The names of the dailyLearning calendars are published here in the Readme, but we need a few more code examples.

https://github.com/hebcal/hebcal-learning/blob/main/README.md