Manual for Jewish Calendar ActiveX Control

Table Of Contents

Methods sorted by group

Date converting from/to the Jewish calendar:

Getting month names:

Getting the length of months or years:

Getting the weekday of a date:

Checking a date:

Converting a date in a number and back:

Yahrzeit calculation:

Methods in alphabetical order

Properties

Gregorian Month Names (Type BSTR)

Jewish Month Names (Type BSTR)

Gregorian Date:

Jewish Date:

AfterSunset (Type boolean)

This variable is set to FALSE by default.
If this variable is set to TRUE, the functions for converting dates from/to the Jewish calendar (Gregorian2Hebrew, Hebrew2Gregorian, G2H, H2G, DateToJewish, JewishToDate, NumberToJewish, JewishToNumber) assume, that the date, which is passed to the function as a parameter and which should be converted, should be the Jewish date which is valid after sunset.

Example: If AfterSunset is set to FALSE, the Gregorian date 14 April 1999 (Friday) is converted into the Jewish date 9 Nisan 5760 (this Jewish day begins on Thursday evening and ends on Friday evening).
If After Sunset has the value TRUE, the 10 Nisan 5760 is got (this Jewish day begins on Friday evening and ends on Saturday evening).

Numbering of the Jewish months

Explanations of methods

Gregorian2Hebrew

The Gregorian2Hebrew function converts a Gregorian date in a Jewish date.

BOOL Gregorian2Hebrew(
  short day,
  short month,
  short year
);

Parameters

day
Day of Gregorian date

month
Month of Gregorian date

year
Year of Gregorian date

Return value

If the function was successful, the return value is TRUE. In the property variables sJewishDay, sJewishMonth and sJewishYear, the Jewish date is put which corresponds to the Gregorian date given to the function.

If an error occured while invoking the function, the return value is FALSE. This is the case if the Gregorian date is invalid.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->Gregorian2Hebrew(17, 6, 1981);
if (fResult)
{
  wsprintf(szText,
           "%d.%d.%d",
           (int) (jc->GetSJewishDay()),
           (int) (jc->GetSJewishMonth()),
           (int) (jc->GetSJewishYear()));
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

Hebrew2Gregorian

The Hebrew2Gregorian function converts a Jewish date in a Gregorian date.

BOOL Hebrew2Gregorian(
  short day,
  short month,
  short year
);

Parameters

day
Day of Jewish date

month
Month of Jewish date

year
Year of Jewish date

Return value

If the function was successful, the return value is TRUE. In the property variables sGregorianDay, sGregorianMonth and sGregorianY, the Gregorian date is put which corresponds to the Jewish date given to the function.

If an error occured while invoking the function, the return value is FALSE. This is the case if the Jewish date is invalid.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->Hebrew2Gregorian(15, 3, 5741);
if (fResult)
{
  wsprintf(szText,
           "%d.%d.%d",
           (int) (jc->GetSGregorianDay()),
           (int) (jc->GetSGregorianMonth()),
           (int) (jc->GetSGregorianY()));
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

G2H

The G2H function converts a Gregorian date into a Jewish date.

BOOL G2H(
  short in_day,
  short in_month,
  short in_year,
  short* out_day,
  short* out_month,
  short* out_year
);

Parameters

in_day
Day of Gregorian date

in_month
Month of Gregorian date

in_year
Year of Gregorian date

out_day
Pointer to variable which will contain the day of the Jewish date

out_month
Pointer to variable which will contain the month of the Jewish date

out_year
Pointer to variable which will contain the year of the Jewish date

Return value

If the function was successful, the return value is TRUE. In the variables out_day, out_month und out_year, the Jewish date is contained which corresponds to the passed Gregorian date.

If an error occured while invoking the function, the return value is FALSE. This is the case if the Gregorian date is invalid.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
char szText[256];
int d, m, y;

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->G2H(17, 6, 1981, &d, &m, &y);
if (fResult)
{
  wsprintf(szText,
           "%d.%d.%d",
           (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

H2G

The H2G function converts a Jewish date into a Gregorian date.

BOOL G2H(
  short in_day,
  short in_month,
  short in_year,
  short* out_day,
  short* out_month,
  short* out_year
);

Parameters

in_day
Day of Jewish date

in_month
Month of Jewish date

in_year
Year of Jewish date

out_day
Pointer to variable which will contain the day of the Gregorian date

out_month
Pointer to variable which will contain the month of the Gregorian date

out_year
Pointer to variable which will contain the year of the Gregorian date

Return value

If the function was successful, the return value is TRUE. In the variables out_day, out_month und out_year, the Gregorian date is contained which corresponds to the passed Jewish date.

If an error occured while invoking the function, the return value is FALSE. This is the case if the Jewish date is invalid.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
char szText[256];
int d, m, y;

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->H2G(15, 3, 5741, &d, &m, &y);
if (fResult)
{
  wsprintf(szText,
           "%d.%d.%d",
           (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

DateToJewish

The DateToJewish function converts a date in the DATE format into a Jewish date.

BOOL DateToJewish(
  DATE* in_date,
  short* j_day,
  short* j_month,
  short* j_year
);

Parameters

in_date
Date in DATE format

j_day
Pointer to variable which will contain the day of the Jewish date

j_month
Pointer to variable which will contain the month of the Jewish date

j_year
Pointer to variable which will contain the year of the Jewish date

Return value

If the function was successful, the return value is TRUE. In the variables j_day, j_month and j_year, the Jewish date is contained which corresponds to the passed date.

If an error occured while invoking the function, the return value is FALSE. This is the case if the passed date is invalid.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
char szText[256];
int d, m, y;

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->DateToJewish(12345, &d, &m, &y);
if (fResult)
{
  wsprintf(szText,
           "%d.%d.%d",
           (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

JewishToDate

The JewishToDate function converts a Jewish date into a date in the DATE format.

BOOL JewishToDate(
  short j_day,
  short j_month,
  short j_year,
  DATE* out_date,
);

Parameters

j_day
Day of Jewish date

j_month
Month of Jewish date

j_year
Year of Jewish date

out_date
Pointer to variable which will contain the date in DATE format

Return value

If the function was successful, the return value is TRUE. In the variable out_date, the converted date is contained in DATE format which corresponds to the passed date.

If an error occured while invoking the function, the return value is FALSE. This is the case if the passed date is invalid.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
char szText[256];
DATE d;

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->JewishToDate(15, 3, 5741, &d);
if (fResult)
{
  wsprintf(szText,
           "%ld", (LONG) d);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

GetGregorianMonthName

The GetGregorianMonthName function returns the month name of a Gregorian month. For getting the month names, the GregorXXX properties are used (see Properties).

BSTR GetGregorianMonthName(
  short sMonthNo
);

Parameters

sMonthNo
Month in Gregorian calendar

Return value

If the function was successful, the function returns a string with the month name which corresponds to the passed Gregorian month.

If an error occured while invoking the function, the returned string is empty. This is the case if the passed month does not exist.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
CString cstr;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
cstr = jc->GetGregorianMonthName(7);
lstrcpy(szText, (LPCSTR) cstr);
if (lstrcmp(szText, "") == 0)
  lstrcpy(szText, "Month is invalid");
MessageBox(szText);
delete jc;

GetJewishMonthName

The GetJewishMonthName function returns the month name of a Jewish month. For getting the month names, the JewishXXX properties are used (see Properties).

BSTR GetJewishMonthName(
  short sMonthNo,
  short sYear
);

Parameters

sMonthNo
Month in Jewish calendar

sYear
Year in Jewish calendar

Return value

If the function was successful, the function returns a string with the month name which corresponds to the passed Jewish month.

If an error occured while invoking the function, the returned string is empty. This is the case if the passed month does not exist.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
CString cstr;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
cstr = jc->GetJewishMonthName(7, 5760);
lstrcpy(szText, (LPCSTR) cstr);
if (lstrcmp(szText, "") == 0)
  lstrcpy(szText, "Month is invalid");
MessageBox(szText);
delete jc;

GetGregorianMonthLength

The GetGregorianMonthLength function returns the length in days of a Gregorian month.

short GetGregorianMonthLength(
  short sMonthNo,
  short sYear
);

Parameters

sMonthNo
Month in Gregorian calendar

sYear
Year in Gregorian calendar

Return value

If the function was successful, the return value is the count of days in the passed month.

If, while invoking the function, an error occured, the return value is 0. This is the case if the passed month does not exist.

Sample code

CJewCal* jc;
RECT rect;
int iMonthLength;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
iMonthLength = jc->GetGregorianMonthLength(2, 1997);
if (iMonthLength)
{
  wsprintf(szText, "%d", (int) iMonthLength);
  MessageBox(szText);
}
else
  MessageBox("Month is invalid");
delete jc;

GetJewishMonthLength

The GetJewishMonthLength function returns the length in days of a Jewish month.

short GetJewishMonthLength(
  short sMonthNo,
  short sYear
);

Parameters

sMonthNo
Month in Jewish calendar

sYear
Year in Jewish calendar

Return value

If the function was successful, the return value is the count of days in the passed month.

If, while invoking the function, an error occured, the return value is 0. This is the case if the passed month does not exist.

Sample code

CJewCal* jc;
RECT rect;
int iMonthLength;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
iMonthLength = jc->GetJewishMonthLength(2, 5760);
if (iMonthLength)
{
  wsprintf(szText, "%d", (int) iMonthLength);
  MessageBox(szText);
}
else
  MessageBox("Month is invalid");
delete jc;

GetJewishYearLength

The GetJewishYearLength function returns the length in month of a Jewish year.

short GetJewishYearLength(
  short sYear
);

Parameters

sYear
Year in Jewish calendar

Return value

If the function was successful, the return value is the count of months in the passed year.

If, while invoking the function, an error occured, the return value is 0. This is the case if the passed year does not exist.

Sample code

CJewCal* jc;
RECT rect;
int iYearLength;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
iYearLength = jc->GetJewishYearLength(5760);
if (iYearLength)
{
  wsprintf(szText, "%d", (int) iYearLength);
  MessageBox(szText);
}
else
  MessageBox("Month is invalid");
delete jc;

GetWeekdayGregorian

The GetWeekdayGregorian function gets the weekday of a Gregorian date.

short GetWeekdayGregorian(
  short sDay,
  short sMonth,
  short sYear
);

Parameters

sDay
Day in Gregorian calendar

sMonth
Month in Gregorian calendar

sYear
Year in Gregorian calendar

Return value

If the function was successful, the return value is the searched weekday. The following assignment applies:

If, while invoking the function, an error occured, the return value is (-1). This is the case if the passed date is invalid.

Sample code

CJewCal* jc;
RECT rect;
int iWeekday;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
iWeekday = jc->GetWeekdayGregorian(17, 6, 1981);
if (iWeekday != (-1))
{
  lstrcpy(szText, "");
  switch(iWeekday)
  {
    case 0: lstrcpy(szText, "Sunday"); break;
    case 1: lstrcpy(szText, "Monday"); break;
    case 2: lstrcpy(szText, "Tuesday"); break;
    case 3: lstrcpy(szText, "Wednesday"); break;
    case 4: lstrcpy(szText, "Thursday"); break;
    case 5: lstrcpy(szText, "Friday"); break;
    case 6: lstrcpy(szText, "Saturday"); break;
  }
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

GetWeekdayJewish

The GetWeekdayJewish function gets the weekday of a Jewish date.

short GetWeekdayJewish(
  short sDay,
  short sMonth,
  short sYear
);

Parameters

sDay
Day in Jewish calendar

sMonth
Month in Jewish calendar

sYear
Year in Jewish calendar

Return value

If the function was successful, the return value is the searched weekday. The following assignment applies:

If, while invoking the function, an error occured, the return value is (-1). This is the case if the passed date is invalid.

Sample code

CJewCal* jc;
RECT rect;
int iWeekday;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
iWeekday = jc->GetWeekdayJewish(15, 3, 5741);
if (iWeekday != (-1))
{
  lstrcpy(szText, "");
  switch(iWeekday)
  {
    case 0: lstrcpy(szText, "Sunday"); break;
    case 1: lstrcpy(szText, "Monday"); break;
    case 2: lstrcpy(szText, "Tuesday"); break;
    case 3: lstrcpy(szText, "Wednesday"); break;
    case 4: lstrcpy(szText, "Thursday"); break;
    case 5: lstrcpy(szText, "Friday"); break;
    case 6: lstrcpy(szText, "Saturday"); break;
  }
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

IsValidGregorian

The IsValidGregorian function checks if the passed Gregorian date is valid.

short IsValidGregorian(
  short sDay,
  short sMonth,
  short sYear
);

Parameters

sDay
Day in Gregorian calendar

sMonth
Month in Gregorian calendar

sYear
Year in Gregorian calendar

Return value

If the date is valid, the return value is TRUE, otherwise FALSE.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->IsValidGregorian(17, 6, 1981);
if (fResult)
  MessageBox("Date is valid");
else
  MessageBox("Date is invalid");
delete jc;

IsValidJewish

The IsValidJewish function checks if the passed Gregorian date is valid.

short IsValidJewish(
  short sDay,
  short sMonth,
  short sYear
);

Parameters

sDay
Day in Jewish calendar

sMonth
Month in Jewish calendar

sYear
Year in Jewish calendar

Return value

If the date is valid, the return value is TRUE, otherwise FALSE.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->IsValidJewish(15, 3, 5741);
if (fResult)
  MessageBox("Date is valid");
else
  MessageBox("Date is invalid");
delete jc;

JewishToNumber

The JewishToNumber function converts the passed Jewish date into a number. The unit of this number is days and has the characteristic that, if it is increased respectively decreased by 1, the next respectively the previous day is represented. This number can be, for example, used to get, with the aid of the function NumberToJewish, the day, which is n days before or after a desired day, or the difference between two dates.

long JewishToNumber(
  short sDay,
  short sMonth,
  short sYear
);

Parameters

sDay
Day in Jewish calendar

sMonth
Month in Jewish calendar

sYear
Year in Jewish calendar

Return value

If the date is valid, the return value is the calculated number, otherwise 0.

Sample code

CJewCal* jc;
RECT rect;
LONG lNumber;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
lNumber = jc->JewishToNumber(15, 3, 5741);
if (lNumber)
{
  wsprintf(szText, "%ld", (LONG) lNumber);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

NumberToJewish

The NumberToJewish function converts the passed number into a Jewish date. The unit of this number is days and has the characteristic that, if it is increased respectively decreased by 1, the next respectively the previous day is represented. This number can be, for example, used to get, with the aid of the function JewishToNumber, the day, which is n days before or after a desired day, or the difference between two dates.

BOOL NumberToJewish(
  long lNumber,
  short* sDay,
  short* sMonth,
  short* sYear
);

Parameters

lNumber
Number which should be converted

sDay
Pointer to variable which will contain the day in the Jewish calendar

sMonth
Pointer to variable which will contain the month in the Jewish calendar

sYear
Pointer to variable which will contain the year in the Jewish calendar

Return value

If the number is valid, the return value is TRUE, and the variables sDay, sMonth and sYear contain the converted date.

If the number is invalid, the return value is FALSE.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
int d, m, y;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->NumberToJewish(723348, &d, &m, &y);
if (fResult)
{
  wsprintf(szText, "%d.%d.%d", (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Number is invalid");
delete jc;

GregorianToNumber

The GregorianToNumber function converts the given Gregorian date into a number. The unit of this number is days and has the characteristic that, if it is increased respectively decreased by 1, the next respectively the previous day is represented. This number can be, for example, used to get, with the aid of the function NumberToGregorian, the day, which is n days before or after a desired day, or the difference between two dates.

long GregorianToNumber(
  short sDay,
  short sMonth,
  short sYear
);

Parameters

sDay
Day in Gregorian calendar

sMonth
Month in Gregorian calendar

sYear
Year in Gregorian calendar

Return value

If the date is valid, the return value is the calculated number, otherwise 0.

Sample code

CJewCal* jc;
RECT rect;
LONG lNumber;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
lNumber = jc->GregorianToNumber(17, 6, 1981);
if (lNumber)
{
  wsprintf(szText, "%ld", (LONG) lNumber);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

NumberToGregorian

The NumberToGregorian function converts the given number into a Gregorian date. The unit of this number is days and has the characteristic that, if it is increased respectively decreased by 1, the next respectively the previous day is represented. This number can be, for example, used to get, with the aid of the function GregorianToNumber, the day, which is n days before or after a desired day, or the difference between two dates.

BOOL NumberToGregorian(
  long lNumber,
  short* sDay,
  short* sMonth,
  short* sYear
);

Parameters

lNumber
Number which should be converted

sDay
Pointer to variable which will contain the day in the Gregorian calendar

sMonth
Pointer to variable which will contain the month in the Gregorian calendar

sYear
Pointer to variable which will contain the year in the Gregorian calendar

Return value

If the number is valid, the return value is TRUE, and the variables sDay, sMonth and sYear contain the converted date.

If the number is invalid, the return value is FALSE.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
int d, m, y;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
fResult = jc->NumberToGregorian(723348, &d, &m, &y);
if (fResult)
{
  wsprintf(szText, "%d.%d.%d", (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Number is invalid");
delete jc;

CalculateYahrzeit

BOOL CalculateYahrzeit(
  short sDeathDay,
  short sDeathMonth,
  short sDeathYear,
  short sInHebrewYear,
  short* sYahrzeitDay,
  short* sYahrzeitMonth,
  short* sYahrzeitYear
);

Parameters

sDeathDay, sDeathMonth, sDeathYear
Jewish day, month and year of the date on which the person has died for which the Yahrzeit calculation should be performed

Please click here for the assignment of numbers to the Jewish month names

sInHebrewYear
Jewish year of which the Yahrzeit should be calculated

sYahrzeitDay, sYahrzeitMonth, sYahrzeitYear
Pointer to variables which will contain the Jewish day, month and year of the calculated Yahrzeit date

Return value

If the passed death date is valid, the return value is TRUE and the variables sYahrzeitDay, sYahrzeitMonth and sYahrzeitYear contain the calculated Yahrzeit date.

If the passed death date is invalid, the return value is FALSE.

Note

If the property Sephardim is set to TRUE (by default to FALSE), the Yahrzeit calculation is performed according to the Sephardic ritus. This applies to the case if the died person died in the month Adar of a non-leap year and the year, of which the Yahrzeitshould be calculated, is a leap year. According to the non-sephardic ritus (Sephardim is FALSE), the same day in the month Adar I is calculated. If Sephardim is set to TRUE, according to the Sephardic ritus, the same day in the month Adar II is got.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
int d, m, y;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
jc->SetSephardim(FALSE);
fResult = jc->CalculateYahrzeit(17, 6, 5760, 5761, &d, &m, &y);
if (fResult)
{
  wsprintf(szText, "%d.%d.%d", (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

CalculateYahrzeitReturnProp

BOOL CalculateYahrzeitReturnProp(
  short sDeathDay,
  short sDeathMonth,
  short sDeathYear,
  short sInHebrewYear
);

Parameters

sDeathDay, sDeathMonth, sDeathYear
Jewish day, month and year of the date on which the person has died for which the Yahrzeit calculation should be performed

Please click here for the assignment of numbers to the Jewish month names

sInHebrewYear
Jewish year of which the Yahrzeit should be calculated

Return value

If the passed death date is valid, the return value is TRUE and the properties sJewishDay, sJewishMonth and sJewishYear contain the calculated Yahrzeit date.

If the passed death date is invalid, the return value is FALSE.

Note

If the property Sephardim is set to TRUE (by default to FALSE), the Yahrzeit calculation is performed according to the Sephardic ritus. This applies to the case if the died person died in the month Adar of a non-leap year and the year, of which the Yahrzeitshould be calculated, is a leap year. According to the non-sephardic ritus (Sephardim is FALSE), the same day in the month Adar I is calculated. If Sephardim is set to TRUE, according to the Sephardic ritus, the same day in the month Adar II is got.

Sample code

CJewCal* jc;
RECT rect;
BOOL fResult;
int d, m, y;
char szText[256];

jc = new CJewCal();
SetRect(&rect, 0, 0, 100, 100);
jc->Create(NULL, "", WS_OVERLAPPEDWINDOW,
           rect, AfxGetMainWnd(), 1);
jc->SetSephardim(FALSE);
fResult = jc->CalculateYahrzeitReturnProp(17, 6, 5760, 5761);
if (fResult)
{
  d = jc->GetSJewishDay();
  m = jc->GetSJewishMonth();
  y = jc->GetSJewishYear();
  wsprintf(szText, "%d.%d.%d", (int) d, (int) m, (int) y);
  MessageBox(szText);
}
else
  MessageBox("Date is invalid");
delete jc;

Using the ActiveX Control in Office 2013

The ActiveX control can be used in own macros which can be created by selecting in the ribbon Developer the item Visual Basic.
Hint: if the ribbon Developer is not visible, click on File, Options, Customize Ribbon. In the combobox Choose command from: select the entry Main Tabs and then in the list the item Developer, finally click on Add >>.

The ActiveX Control is loaded by the following commands:

Dim t As Object
Set t = CreateObject("JEWCAL.JewCalCtrl.1")

Some examples for calling functions follow.

Invoking a simple function which takes numbers as parameters and returns a number:

Dim Weekday As Integer
Weekday = t.GetWeekdayGregorian(17, 6, 1981)
MsgBox Str$(Weekday)

Invoking a function with integer return values (parameters of such functions, which operate as return value, are marked in the respective description with short*):

Dim d As Integer
Dim m As Integer
Dim y As Integer
Result = t.G2H(17, 6, 1981, d, m, y)
If Result Then
    A$ = Str$(d) + "." + Str$(m) + "." + Str$(y)
    MsgBox A$
End If

Invoking a function with return value as properties (functions Gregorian2Hebrew and Hebrew2Gregorian):

Result = t.Gregorian2Hebrew(18, 6, 1981)
If Result Then
    A$ = Str$(t.sJewishDay) + "." + Str$(t.sJewishMonth)
    A$ = A$ + "." + Str$(t.sJewishYear)
    MsgBox A$
End If

Invoking a function which returns a String (functions GetGregorianMonthName and GetJewishMonthName):

Dim Month As String
Month = t.GetGregorianMonthName(7)
MsgBox Month$

Setting a property (Gregorian and Jewish month names):

t.GregorJuly = "Juli"

Using the ActiveX control in Visual C#

using AxJEWCALLib;
using System;
using System.Drawing;
using System.Windows.Forms;

public class Sample
{
  [STAThread]
  public static void Main()
  {
    // Create invisible form which will later contain the Jewish
    // Calendar ActiveX Control
    Form form = new Form();
    form.FormBorderStyle = FormBorderStyle.None;
    form.ShowInTaskbar = false;
    form.Show();
    form.Size = new Size(0, 0);

    // Create the invisible Jewish Calendar ActiveX Control and
    // add it to the form
    AxJewCal jewcal = new AxJewCal();
    form.Controls.Add(jewcal);
    jewcal.Size = new Size(0, 0);

    // Convert a Gregorian to a Jewish date
    short jday = 0, jmonth = 0, jyear = 0;
    if (jewcal.G2H(17, 6, 1981, ref jday, ref jmonth, ref jyear))
    {
      Console.WriteLine("17 June 1981 is Jewish day " +
                        jday + ", month " + jmonth + ", year " + jyear);
    }
  }
}

To compile a program which uses the Jewish Calendar ActiveX Control, use the aximp utility included in the .NET SDK to generate the AxJEWCALLib.dll library and then use a reference to it to compile the source code. Here is an example of a batch file for building the application:

aximp C:\JEWCAL\JEWCAL.OCX
csc /platform:x86 /r:AxJEWCALLib.dll sample.cs

Using the ActiveX control in VB.NET

Imports AxJEWCALLib
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class Sample
  <STAThread()>
  Public Shared Sub Main()
    ' Create invisible form which will later contain the Jewish
    ' Calendar ActiveX Control
    Dim form As New Form
    form.FormBorderStyle = FormBorderStyle.None
    form.ShowInTaskbar = False
    form.Show
    form.Size = New Size(0, 0)

    ' Create the invisible Jewish Calendar ActiveX Control and
    ' add it to the form
    Dim jewcal As New AxJewCal
    form.Controls.Add(jewcal)
    jewcal.Size = New Size(0, 0)

    ' Convert a Gregorian to a Jewish date
    Dim jday As Short, jmonth As Short, jyear As Short
    If jewcal.G2H(17, 6, 1981, jday, jmonth, jyear) Then
      Console.WriteLine("17 June 1981 is Jewish day " &
                        jday & ", month " & jmonth & ", year " & jyear)
    End If
  End Sub
End Class

To compile a program which uses the Jewish Calendar ActiveX Control, use the aximp utility included in the .NET SDK to generate the AxJEWCALLib.dll library and then use a reference to it to compile the source code. Here is an example of a batch file for building the application:

aximp C:\JEWCAL\JEWCAL.OCX
vbc /platform:x86 /r:AxJEWCALLib.dll sample.vb

Using the ActiveX control in Visual C++ by using ATL.DLL and the IDispatch interface

#include <windows.h>
#include <stdio.h>

// Gets a property of the type "short". Returns -1 when an error occured.
short GetShortProperty(IDispatch* pDisp, LPWSTR lpwName)
{
  LPWSTR awszNames[1] = {lpwName};
  DISPID dispid;
  HRESULT hr = pDisp->GetIDsOfNames(IID_NULL, &awszNames[0], 1, LOCALE_SYSTEM_DEFAULT, &dispid);
  if (SUCCEEDED(hr))
  {
    DISPPARAMS dispparams = {NULL, NULL, 0, 0};
    VARIANT varResult;
    VariantInit(&varResult);
    hr = pDisp->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dispparams, &varResult, NULL, NULL);
    if (SUCCEEDED(hr))
    {
      if (V_VT(&varResult) == VT_I2)
        return V_I2(&varResult);
      else
        return -1;
    }
    else
      return -1;
  }
  else
    return -1;
}

// Invokes the Gregorian2Hebrew method with the given parameters and returns its
// return value
BOOL InvokeGregorian2Hebrew(IDispatch* pDisp, short sDay, short sMonth, short sYear)
{
  LPWSTR awszNames[1] = {L"Gregorian2Hebrew"};
  DISPID dispid;
  HRESULT hr = pDisp->GetIDsOfNames(IID_NULL, &awszNames[0], 1, LOCALE_SYSTEM_DEFAULT, &dispid);
  if (SUCCEEDED(hr))
  {
    VARIANT varg[3];
    VariantInit(&varg[2]);
    V_VT(&varg[2]) = VT_I2;
    V_I2(&varg[2]) = sDay;
    VariantInit(&varg[1]);
    V_VT(&varg[1]) = VT_I2;
    V_I2(&varg[1]) = sMonth;
    VariantInit(&varg[0]);
    V_VT(&varg[0]) = VT_I2;
    V_I2(&varg[0]) = sYear;
    DISPPARAMS dispparams = {&varg[0], NULL, 3, 0};
    VARIANT varResult;
    VariantInit(&varResult);
    hr = pDisp->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparams, &varResult, NULL, NULL);
    if (SUCCEEDED(hr))
    {
      if (V_BOOL(&varResult) == VARIANT_TRUE)
        return TRUE;
      else
        return FALSE;
    }
    else
      return FALSE;
  }
  else
    return FALSE;
}

// Custom types for pointers to functions in ATL.DLL
typedef BOOL (CALLBACK* LPFNATLAXWININIT) ();
typedef HRESULT (CALLBACK* LPFNATLAXGETCONTROL) (HWND, IUnknown**);

void main(void)
{
  // Load the ATL.DLL library
  HINSTANCE hinstATL = LoadLibrary("ATL.DLL");
  if (hinstATL)
  {
    // Get functions of ATL.DLL
    LPFNATLAXWININIT lpfnAtlAxWinInit = (LPFNATLAXWININIT) GetProcAddress(hinstATL, "AtlAxWinInit");
    LPFNATLAXGETCONTROL lpfnAtlAxGetControl = (LPFNATLAXGETCONTROL) GetProcAddress(hinstATL, "AtlAxGetControl");
    if (lpfnAtlAxWinInit && lpfnAtlAxGetControl)
    {
      // Initialize ATL.DLL
      BOOL fResult = (*lpfnAtlAxWinInit) ();
      if (fResult)
      {
        // Create a window which contains the Jewish Calendar ActiveX Control
        HWND hwnd = CreateWindow("AtlAxWin",
                                 "{01D39D9A-C397-11D3-BFE0-8BDCA129FE09}",
                                 WS_OVERLAPPED, 0, 0, 0, 0,
                                 NULL, NULL, GetModuleHandle(NULL), NULL);
        if (hwnd)
        {
          // Get the IUnknown interface of the Jewish Calendar ActiveX Control
          IUnknown* pUnk = NULL;
          HRESULT hr = (*lpfnAtlAxGetControl) (hwnd, &pUnk);
          if (SUCCEEDED(hr))
          {
            // Get the IDispatch interface of the Jewish Calendar ActiveX Control
            IDispatch* pDisp = NULL;
            hr = pUnk->QueryInterface(IID_IDispatch, (void**) &pDisp);
            if (SUCCEEDED(hr))
            {
              // Convert a Gregorian to a Jewish date
              if (InvokeGregorian2Hebrew(pDisp, 17, 6, 1981))
              {
                // Show the converted date
                short sDay = GetShortProperty(pDisp, L"sJewishDay");
                short sMonth = GetShortProperty(pDisp, L"sJewishMonth");
                short sYear = GetShortProperty(pDisp, L"sJewishYear");
                printf("17 June 1981 is Jewish day %d, month %d, year %d\n",
                       (int) sDay, (int) sMonth, (int) sYear);
              }
              pDisp->Release();
            }
            pUnk->Release();
          }
          DestroyWindow(hwnd);
        }
      }
    }
    FreeLibrary(hinstATL);
  }
}

Makefile for compiling the source code:

LIBS = user32.lib ole32.lib oleaut32.lib

all : sample.exe

sample.exe : sample.obj
	link /out:sample.exe sample.obj $(LIBS)

sample.obj : sample.cpp
	cl /c sample.cpp

clean :
	del sample.obj
	del sample.exe

Using the ActiveX control in Visual C++ by using the IDE

In the menu Project, the menu items Add to project... and Components and Controls... have to be selected.
In the appearing list, the entry Registered ActiveX Controls and then the entry JewCal Control have to be clicked on twice.
The message box, in which Insert this component? appears, has to be confirmed with a click on OK.
The settings in the now appearing dialog box Confirm Classes should not be modified and confirmed with a click on OK.
The dialog box with the list of the ActiveX controls has to be closed with a click on Close.
Now, in the class window, the new class CJewCal appears with which you can access the methods and properties of the ActiveX control.

The month names of the Gregorian and Jewish calendar can be set by calling the SetXXX procedure.
If jc is an already initialized variable of the type CJewCal* and the name of the month Janaur has to be set on "Januar", you have to type:

jc->SetGregorJanuar("Januar");

Hint: To determine at running time if the ActiveX control is installed on the system, you can use the following code, e.g. in the function InitInstance:

LONG lErrorCode;
HKEY hkeyValue;

lErrorCode = RegOpenKey(HKEY_CLASSES_ROOT,
                        "JEWCAL.JewCalCtrl.1",
                        &hkeyValue);
if (lErrorCode != ERROR_SUCCESS)
{
  ::MessageBox(NULL,
               "ActiveX Control could not be found",
               "Error",
               MB_ICONSTOP | MB_OK);
  return FALSE;
}
else
  RegCloseKey(hkeyValue);

License agreement

The software is protected by copyright laws.

The author is not liable for consequential, incidential or indirect damages of any kind which arise out of the use of the software.

Author

Ulrich Greve
Website: http://www.tichnut.de/jewish/