|
hconverter
C code to convert dates between Hebrew, Gregorian and Julian calendars
|
Go to the source code of this file.
Data Structures | |
| struct | hc_date_s |
| struct | heb_time_s |
| Hebrew time: hour and parts. More... | |
Typedefs | |
| typedef enum hc_day_of_week | hc_day_of_week |
| typedef enum hc_calendar_type | hc_calendar_type |
| Supported types of calendar. More... | |
| typedef struct hc_date_s | hc_date |
| typedef struct heb_time_s | heb_time |
| Hebrew time: hour and parts. More... | |
| typedef enum heb_year_type | heb_year_type |
| enum of possible layouts of the variable length Hebrew months Cheshvan and Kislev in a given year. More... | |
Enumerations | |
| enum | hc_day_of_week { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } |
| enum | hc_calendar_type { NONE, GREGORIAN, JULIAN, HEBREW } |
| Supported types of calendar. More... | |
| enum | heb_year_type { SHORT_HEB_YEAR, NORMAL_HEB_YEAR, FULL_HEB_YEAR } |
| enum of possible layouts of the variable length Hebrew months Cheshvan and Kislev in a given year. More... | |
Functions | |
| int | set_hc_date (hc_date *, int year, int month, int day, hc_calendar_type) |
| int | hc_convert (hc_date *date, hc_calendar_type target_calendar) |
| This function converts a date from one calendar to another. More... | |
| int | hc_check (hc_date *date) |
| Check validity of data in hc_date. More... | |
| int | hc_is_leap_year (int year, hc_calendar_type calendar_type) |
| Check if year is leap in given calendar. More... | |
| hc_day_of_week | hc_get_day_of_week (hc_date *date) |
| Function to get day of week out of a hc_date. More... | |
| int | hc_get_month_length (int year, int month, hc_calendar_type calendar_type) |
| Function to get the length of a month. More... | |
| int | hc_compute_keviut (const int year, int *rosh_hashana_dow, int *pesach_dow, int *ck, int *leap) |
| Compute year "keviut" and put the result into 4 integers. More... | |
| int | hc_set_hc_heb_time (heb_time *time, int hour, int part) |
| Convenience method to set heb_time struct value. More... | |
| int | hc_compute_molad_rosh_hashana (int year, hc_calendar_type cal_type, hc_date *date, heb_time *time) |
| Compute the date time of molad of Rosh Hashana for given year. More... | |
| int | hc_compute_molad (const int year, int month, const hc_calendar_type cal_type, hc_date *date, heb_time *time) |
| Compute the date and time of molad (new moon according to the Hebrew calendar) for given year and month. More... | |
| heb_year_type | hc_get_heb_year_type (int year) |
| Compute number of days in excess of 58 in Cheshvan and Kislev combined. More... | |
Contains all functional offerings of this library: convert dates between Hebrew, Gregorian and Julian calendars as well as compute certain specific times for the new moon, types of Jewish year.
Although each Hebrew year starts with the month of Tishrei, Tishrei is not the first in the order of months. There are a couple of reasons for this. Nisan is called the "first month" in the Torah for most purposes. Also, on a Hebrew leap year the 13th month (adar 2) is added before Nisan, not before Tishrei. This makes it more convenient to senumerate months not in chronological order but rather starting from Nisan to the end of year (Elul), and then returning to Tishrei through Adar. Thus the Hebrew months here are represented by integers as follows:
Tishrei 7 Cheshvan 8 Kislev 9 Teveth 10 Shvat 11 Adar 12 (also Adar I on leap years) Adar II 13 (only on Hebrew leap years) Nisan 1 Iyar 2 Sivan 3 Tamuz 4 Menachem Av 5 Elul 6so despite a lower month index, Nisan follows after Adar. For example, the date 5776-01-01 follows 5776-13-29 in yyyy-mm-dd notation.
Keviut determines layout of the Jewish year, including all holidays and readings of the Torah. It is customary to abbreviate it to 4 parameters:
Only 14 combinations of these are actually possible.
| typedef enum hc_calendar_type hc_calendar_type |
Supported types of calendar.
| typedef enum hc_day_of_week hc_day_of_week |
Convenience enum for days of week: SUNDAY=0, MONDAY=1, ..., FRIDAY=6
| typedef struct heb_time_s heb_time |
Hebrew time: hour and parts.
This type is specific to Hebrew calendar. Time is measured in hours and chalokim ("parts"), which are 1/1080 of an hour.
| typedef enum heb_year_type heb_year_type |
enum of possible layouts of the variable length Hebrew months Cheshvan and Kislev in a given year.
| enum hc_calendar_type |
Supported types of calendar.
| enum hc_day_of_week |
Convenience enum for days of week: SUNDAY=0, MONDAY=1, ..., FRIDAY=6
| enum heb_year_type |
enum of possible layouts of the variable length Hebrew months Cheshvan and Kislev in a given year.
| int hc_check | ( | hc_date * | date | ) |
Check validity of data in hc_date.
Returns 1 if the date is valid, 0 if the date is invalid in corresponding calendar. The following are invalid: nonpositive Hebrew year, month less than 1 or more than number of months in given year, day less than one or more than days in month.
| [in] | date | an hc_date |
| int hc_compute_keviut | ( | const int | year, |
| int * | rosh_hashana_dow, | ||
| int * | pesach_dow, | ||
| int * | ck, | ||
| int * | leap | ||
| ) |
Compute year "keviut" and put the result into 4 integers.
Keviut determines layout of the Jewish year, including all holidays and readings of the Torah. See keviut for more information. Here, we output the "keviut" parameters by setting values of 4 integers whose pointers are supplied with parameters. For any of these output parameters, null pointers are allowed and will be ignored, so users can pass NULL rather than allocate integers for output that they do not need.
| [in] | year | Hebrew year |
| [out] | rosh_hashana_dow | Day of week for Eosh Hashana (1 Tishrei) |
| [out] | pesach_dow | Day of week for Pesach (0 = saturday) |
| [out] | ck | returns 0, 1, 2 (SHORT, REGULAR, FULL) for number of days in excess of 58 in Chesh=van and Kislev combined. (see #hc_heb_year_type) |
| [out] | it | will return 1 for leap years and 0 otherwise |
| int hc_compute_molad | ( | const int | year, |
| int | month, | ||
| const hc_calendar_type | cal_type, | ||
| hc_date * | date, | ||
| heb_time * | time | ||
| ) |
| int hc_compute_molad_rosh_hashana | ( | int | year, |
| hc_calendar_type | cal_type, | ||
| hc_date * | date, | ||
| heb_time * | time | ||
| ) |
| int hc_convert | ( | hc_date * | date, |
| hc_calendar_type | target_calendar | ||
| ) |
This function converts a date from one calendar to another.
The given hc_date structure is modified during this call, so no new memory is allocated here.
| [out] | date | This object will be modified so that it has the target hc_calendar_type set along with corresponding date. |
| [in] | target_calendar | see hc_calendar_type |
| hc_day_of_week hc_get_day_of_week | ( | hc_date * | date | ) |
Function to get day of week out of a hc_date.
| date |
| heb_year_type hc_get_heb_year_type | ( | int | year | ) |
Compute number of days in excess of 58 in Cheshvan and Kislev combined.
| [in] | year | Hebrew year >=1 |
| int hc_get_month_length | ( | int | year, |
| int | month, | ||
| hc_calendar_type | calendar_type | ||
| ) |
Function to get the length of a month.
| [in] | year | |
| [in] | month. | For Hebrew, see (note) about the special month order. |
| [in] | calendar_type | see hc_calendar_type |
| int hc_is_leap_year | ( | int | year, |
| hc_calendar_type | calendar_type | ||
| ) |
Check if year is leap in given calendar.
For Gregorian or Julian calendar this means that length of the year is 366 days. In Hebrew calendar it means that the year has 13 months instead of 12.
| [in] | year | Hebrew year >=1 |
| [in] | calendar_type | see hc_calendar_type |
| int hc_set_hc_heb_time | ( | heb_time * | time, |
| int | hour, | ||
| int | part | ||
| ) |
Convenience method to set heb_time struct value.
| param[out] | time |
| param[in] | hour |
| param[in] | part |
| int set_hc_date | ( | hc_date * | , |
| int | year, | ||
| int | month, | ||
| int | day, | ||
| hc_calendar_type | |||
| ) |
1.8.10