src/hdate.h(3)
okay bestie, welcome to src/hdate.h, section 3 of the libhdate C language manual π
this is the header file that makes the whole Hebrew calendar thing go, and we are gonna go through every single line of it together. grab a snack. π
πΈ NAME πΈ
src/hdate.h β
libhdate C language header. that's it, that's the name, she's simple and she knows it β¨
π SYNOPSIS π
π Data Structures π
struct hdate_structβ libhdate Hebrew date struct. the main character of this whole file π
π¦ Defines π¦
#define HDATE_DIASPORA_FLAG -1β use diaspora dates and holydays flag#define HDATE_ISRAEL_FLAG 0β use israel dates and holydays flag#define HDATE_SHORT_FLAG -1β use short strings flag#define HDATE_LONG_FLAG 0β use long strings flag#define HEBREW_NUMBER_BUFFER_SIZE 17β forhdate_get_int_string_andhdate_get_int_wstring#define HEBREW_WNUMBER_BUFFER_SIZE 9#define HDATE_STRING_INT 0β for functionhdate_string: identifies string type: integer#define HDATE_STRING_DOW 1β for functionhdate_string: identifies string type: day of week#define HDATE_STRING_PARASHA 2β for functionhdate_string: identifies string type: parasha#define HDATE_STRING_HMONTH 3β for functionhdate_string: identifies string type: hebrew_month#define HDATE_STRING_GMONTH 4β for functionhdate_string: identifies string type: gregorian_month#define HDATE_STRING_HOLIDAY 5β for functionhdate_string: identifies string type: holiday#define HDATE_STRING_OMER 6#define HDATE_STRING_SHORT 1β for functionhdate_string: use short form, if one exists#define HDATE_STRING_LONG 0β for functionhdate_string: use long form#define HDATE_STRING_HEBREW 1β for functionhdate_string: use embedded hebrew string#define HDATE_STRING_LOCAL 0β for functionhdate_string: use local locale string
β Functions β
hdate_struct * hdate_set_gdate (hdate_struct *h, int d, int m, int y)β compute date structure from the Gregorian datehdate_struct * hdate_set_hdate (hdate_struct *h, int d, int m, int y)β compute date structure from the Hebrew datehdate_struct * hdate_set_jd (hdate_struct *h, int jd)β compute date structure from the Julian daychar * hdate_get_format_date (hdate_struct const *h, int diaspora, int s)β Return a string, with the hebrew date.int hdate_get_parasha (hdate_struct const *h, int diaspora)β get the number of hebrew parasha.int hdate_get_holyday (hdate_struct const *h, int diaspora)β get the number of hebrew holiday.char * hdate_get_int_string (int n)β convert an integer to hebrew string.char * hdate_get_day_string (int day, int s)β Return a static string, with name of week day.char * hdate_get_month_string (int month, int s)β Return a static string, with name of month.char * hdate_get_hebrew_month_string (int month, int s)β Return a static string, with name of hebrew month.char * hdate_get_holyday_string (int holyday, int s)β Name of hebrew holiday.char * hdate_get_parasha_string (int parasha, int s)β Name of Parasha.char * hdate_get_omer_string (int omer_day)β Return a static string, with the day in the omer.int hdate_get_omer_day (hdate_struct const *h)β Return the day in the omer of the given date.int hdate_get_holyday_type (int holyday)β Return number of hebrew holyday type.int hdate_get_size_of_hebrew_year (int hebrew_year)β size of hebrew year in days.int hdate_days_from_3744 (int hebrew_year)β Days since Tishrey 3744.int hdate_get_year_type (int size_of_year, int new_year_dw)β Return Hebrew year type based on size and first week day of year.int hdate_gdate_to_jd (int day, int month, int year)β Compute Julian day from Gregorian date.int hdate_hdate_to_jd (int day, int month, int year, int *jd_tishrey1, int *jd_tishrey1_next_year)β Compute Julian day from Hebrew day, month and year.void hdate_jd_to_gdate (int jd, int *day, int *month, int *year)β Converting from the Julian day to the Gregorian date.void hdate_jd_to_hdate (int jd, int *day, int *month, int *year, int *jd_tishrey1, int *jd_tishrey1_next_year)β Converting from the Julian day to the Hebrew day.int hdate_get_day_of_year (int day, int month, int year)β days from 1 januaryvoid hdate_get_utc_sun_time_deg (int day, int month, int year, double latitude, double longitude, double deg, int *sunrise, int *sunset)β utc sun times for altitude at a gregorian datevoid hdate_get_utc_sun_time (int day, int month, int year, double latitude, double longitude, int *sunrise, int *sunset)β utc sunrise/set time for a gregorian datevoid hdate_get_utc_sun_time_full (int day, int month, int year, double latitude, double longitude, int *sun_hour, int *first_light, int *talit, int *sunrise, int *midday, int *sunset, int *first_stars, int *three_stars)β utc sunrise/set time for a gregorian dateint hdate_get_gday (hdate_struct const *h)β get the Gregorian day of the monthint hdate_get_gmonth (hdate_struct const *h)β get the Gregorian monthint hdate_get_gyear (hdate_struct const *h)β get the Gregorian yearint hdate_get_hday (hdate_struct const *h)β get the Hebrew day of the monthint hdate_get_hmonth (hdate_struct const *h)β get the Hebrew monthint hdate_get_hyear (hdate_struct const *h)β get the Hebrew yearint hdate_get_day_of_the_week (hdate_struct const *h)β get the day of the weekint hdate_get_size_of_year (hdate_struct const *h)β get the size of the hebrew yearint hdate_get_new_year_day_of_the_week (hdate_struct const *h)β get the new year day of the weekint hdate_get_julian (hdate_struct const *h)β get the Julian day numberint hdate_get_days (hdate_struct const *h)β get the number of days passed since 1 tishreyint hdate_get_weeks (hdate_struct const *h)β get the number of weeks passed since 1 tishreyhdate_struct * new_hdate ()β creat a new hdate struct object, must be deleted using delete_hdate.hdate_struct * delete_hdate (hdate_struct *h)β delete an hdate struct object.char * hdate_get_version_string ()β Return a static string, with the package name and version.char * hdate_get_translator_string ()β name of translatorint hdate_is_hebrew_locale ()β helper function to find hebrew localechar * hdate_string (int type_of_string, int index, int short_form, int hebrew_form)β Return string values for hdate information.
π Detailed Description π
libhdate C language header.
libhdate - Hebrew calendar library, the C language header file. periodt. that's the whole vibe of the file β she's a header, she declares things, she does not compute them, and honestly? iconic. π
π Define Documentation π
π #define HDATE_DIASPORA_FLAG -1 π
use diaspora dates and holydays flag
π #define HDATE_ISRAEL_FLAG 0 π
use israel dates and holydays flag
π #define HDATE_SHORT_FLAG -1 π
use short strings flag
π #define HDATE_LONG_FLAG 0 π
use long strings flag
π #define HEBREW_NUMBER_BUFFER_SIZE 17 π
for hdate_get_int_string_ and hdate_get_int_wstring
Note: How large should the buffer be? Hebrew year 10,999 would beΧ'ΧͺΧͺΧ§Χ¦"Χ, eight characters, each two bytes, plus an end-of-string delimiter, equals 17. This could effectively yield a range extending to Hebrew year 11,899,Χ'Χ ΧͺΧͺΧ¦'Χ, due to the extra Χ§ needed for the '900' century. However, for readability, I would want a an extra space at that point between the millennium and the century...
the way the author did the math on this and then immediately went "but actually I want a space there" π fr fr, respect.
π #define HEBREW_WNUMBER_BUFFER_SIZE 9 π
no description, she's mysterious, she said nothing and left π«Ά
π #define HDATE_STRING_INT 0 π
for function hdate_string: identifies string type: integer
π #define HDATE_STRING_DOW 1 π
for function hdate_string: identifies string type: day of week
π #define HDATE_STRING_PARASHA 2 π
for function hdate_string: identifies string type: parasha
π #define HDATE_STRING_HMONTH 3 π
for function hdate_string: identifies string type: hebrew_month
π #define HDATE_STRING_GMONTH 4 π
for function hdate_string: identifies string type: gregorian_month
π #define HDATE_STRING_HOLIDAY 5 π
for function hdate_string: identifies string type: holiday
π #define HDATE_STRING_OMER 6 π
another quiet queen, no notes β¨
π #define HDATE_STRING_SHORT 1 π
for function hdate_string: use short form, if one exists
π #define HDATE_STRING_LONG 0 π
for function hdate_string: use long form
π #define HDATE_STRING_HEBREW 1 π
for function hdate_string: use embedded hebrew string
π #define HDATE_STRING_LOCAL 0 π
for function hdate_string: use local locale string
π₯ Function Documentation π₯
π§ hdate_struct* hdate_set_gdate (hdate_struct *h, intd, intm, inty) π§
compute date structure from the Gregorian date
Parameters:
hpointer this hdate struct.dDay of month 1..31mMonth 1..12 if m or d is 0 return current date.yYear in 4 digits e.g. 2001
Returns:
pointer to this hdate struct
π§ hdate_struct* hdate_set_hdate (hdate_struct *h, intd, intm, inty) π§
compute date structure from the Hebrew date
Parameters:
hpointer this hdate struct.dDay of month 1..31mMonth 1..14 ,(13 - Adar 1, 14 - Adar 2) if m or d is 0 return current date.yYear in 4 digits e.g. 5731
Returns:
pointer to this hdate struct
π§ hdate_struct* hdate_set_jd (hdate_struct *h, intjd) π§
compute date structure from the Julian day
Parameters:
hpointer this hdate struct.jdthe julian day number.
Returns:
pointer to this hdate struct
π§ char* hdate_get_format_date (hdate_struct const *h, intdiaspora, ints) π§
Return a string, with the hebrew date.
Returns:
NULL pointer upon failure or, upon success, a pointer to a string containing the short ( e.g. '1 Tishrey' ) or long (e.g. 'Tuesday 18 Tishrey 5763 Hol hamoed Sukot' ) formatted date. You must free() the pointer after use.
Parameters:
hThehdate_structof the date to print.diasporaif true give diaspora holydaysshort_formatA short flag (true - returns a short string, false returns a long string).
Warning: This was originally written using a local static string, calling for output to be copied away.
not me reading "you must free() the pointer after use" and feeling the pressure π bestie, free your memory. it's the law. π«Ά
π§ int hdate_get_parasha (hdate_struct const *h, intdiaspora) π§
get the number of hebrew parasha.
Parameters:
hpointer this hdate struct.diasporaif true give diaspora readings
Returns:
the number of parasha 1. Bereshit etc.. (55 through 61 are joined strings e.g. Vayakhel Pekudei)
π§ int hdate_get_holyday (hdate_struct const *h, intdiaspora) π§
get the number of hebrew holiday.
Parameters:
hpointer this hdate struct.diasporaif true give diaspora holidays
Returns:
the number of holiday.
π§ char* hdate_get_int_string (intn) π§
convert an integer to hebrew string.
Parameters:
nThe int to convert ( 0 < n < 11000)
Returns:
a string of the hebrew number UTF-8 (logical)
β οΈ Warning β DEPRECATION: this function is literally just a wrapper forhdate_stringnow, and it's on its way out. π« If you call it, you mustfree()the memory that the return value points at. Back in the day it used to dump its output into a local static string and politely suggest you copy it somewhere safe β that era is over bestie. [deprecation date 2011-12-28]
char* hdate_get_day_string (int day, int s)
Hands you a static string with the name of the weekday. Classic.
day_of_weekβ the number of the day,1..7(where1= sun π).short_formβ a short flag (true= sun;false= sunday).
β οΈ Warning β DEPRECATION: this function is now just a wrapper for hdate_string, and it is subject to deprecation. [deprecation date 2011-12-28]
char* hdate_get_month_string (int month, int s)
Returns a static string with the name of the month. cute.
monthβ the number of the month,1..12(where1= jan).short_formβ a short flag.
β οΈ Warning β DEPRECATION: this function is now just a wrapper for hdate_string, and it is subject to deprecation. [deprecation date 2011-12-28]
char* hdate_get_hebrew_month_string (int month, int s)
Returns a static string with the name of the Hebrew month π.
monthβ the number of the month,1..14(1= tishre,13= adar 1,14= adar 2).short_formβ a short flag.
β οΈ Warning β DEPRECATION: this function is now just a wrapper for hdate_string, and it is subject to deprecation. [deprecation date 2011-12-28]
char* hdate_get_holyday_string (int holyday, int s)
Name of the Hebrew holiday β¨.
holidayβ the holiday number.short_textβ a short flag.0= true,!0= false.
β οΈ Warning β DEPRECATION: this function is now just a wrapper for hdate_string, and it is subject to deprecation. [deprecation date 2011-12-28]
char* hdate_get_parasha_string (int parasha, int s)
Name of the Parasha π.
parashaβ the number of the Parasha,1-Bereshit (55through61are joined strings, e.g.Vayakhel Pekudei).short_formβ a short flag.0= true,!0= false.
β οΈ Warning β DEPRECATION: this function is now just a wrapper for hdate_string, and it is subject to deprecation. [deprecation date 2011-12-28]
char* hdate_get_omer_string (int omer_day)
Returns a static string with the day in the omer πΎ.
omer dayβ the day in the omer.
Returns: a pointer to a string with the day in the omer. The caller must free() the pointer after use.
β οΈ Warning β DEPRECATION: this function is now just a wrapper for hdate_string, and it is subject to deprecation.
π Attention: the prior version of this function returned a pointer to a static string buffer. The current version returns a pointer to amalloc()ed buffer and needs to befree()d after use. No cap. [deprecation date 2011-12-28]
int hdate_get_omer_day (hdate_struct const *h)
Tells you which day in the omer a given date falls on.
hβ thehdate_structof the date to use.
Returns: the day in the omer, starting from 1 (or 0 if not in sfirat ha omer).
int hdate_get_holyday_type (int holyday)
Returns the number of the Hebrew holyday type π. Here's the whole roster, bestie:
0β Regular day1β Yom tov (plus yom kippor)2β Erev yom kippur3β Hol hamoed4β Hanuka and purim5β Tzomot6β Independance day and Yom yerushalaim7β Lag baomer ,Tu beav, Tu beshvat8β Tzahal and Holocaust memorial days9β National days
Parameters:
holydayβ the holyday number.
Returns: the number of holyday type.
int hdate_get_size_of_hebrew_year (int hebrew_year)
Size of the Hebrew year, in days π.
hebrew_yearβ the hebrew year.
Returns: size of Hebrew year.
int hdate_days_from_3744 (int hebrew_year)
Days since Tishrey 3744.
Author: Amos Shapir 1984 (rev. 1985, 1992) Yaacov Zamir 2003-2005
Parameters:
hebrew_yearβ the Hebrew year.
Returns: number of days since 3,1,3744.
int hdate_get_year_type (int size_of_year, int new_year_dw)
Returns the Hebrew year type based on the size of the year and the first week day of the year.
Parameters:
size_of_yearβ length of year in days.new_year_dwβ first week day of year.
Returns: the number for year type (1..14).
int hdate_gdate_to_jd (int day, int month, int year)
Computes the Julian day from a Gregorian date ποΈ.
Author: Yaacov Zamir (algorithm from Henry F. Fliegel and Thomas C. Van Flandern ,1968)
Parameters:
dayβ day of month1..31.monthβ month1..12.yearβ year in 4 digits, e.g.2001.
Returns: the julian day number.
int hdate_hdate_to_jd (int day, int month, int year, int *jd_tishrey1, int *jd_tishrey1_next_year)
Computes the Julian day from a Hebrew day, month and year π₯.
Author: Amos Shapir 1984 (rev. 1985, 1992) Yaacov Zamir 2003-2005
Parameters:
dayβ day of month1..31.monthβ month1..14(13- Adar 1,14- Adar 2).yearβ Hebrew year in 4 digits, e.g.5753.jd_tishrey1β return the julian number of 1 Tishrey this year.jd_tishrey1_next_yearβ return the julian number of 1 Tishrey next year.
Returns: the julian day number.
void hdate_jd_to_gdate (int jd, int *day, int *month, int *year)
Converting from the Julian day to the Gregorian date π«.
Author: Yaacov Zamir (Algorithm, Henry F. Fliegel and Thomas C. Van Flandern ,1968)
Parameters:
jdβ Julian day.dayβ return day of month1..31.monthβ return month1..12.yearβ return year in 4 digits, e.g.2001.
void hdate_jd_to_hdate (int jd, int *day, int *month, int *year, int *jd_tishrey1, int *jd_tishrey1_next_year)
Converting from the Julian day to the Hebrew day π.
Author: Yaacov Zamir 2005
Parameters:
jdβ Julian day.dayβ return day of month1..31.monthβ return month1..14(13- Adar 1,14- Adar 2).yearβ return year in 4 digits, e.g.2001.jd_tishrey1β return the julian number of 1 Tishrey this year.jd_tishrey1_next_yearβ return the julian number of 1 Tishrey next year.
int hdate_get_day_of_year (int day, int month, int year)
Days from 1 january.
Parameters:
dayβ this day of month.monthβ this month.yearβ this year.
Returns: the days from 1 jan.
void hdate_get_utc_sun_time_deg (int day, int month, int year, double latitude, double longitude, double deg, int *sunrise, int *sunset)
UTC sun times for a given altitude at a gregorian date π
. Returns the sunset and sunrise times in minutes from 00:00 (utc time) if sun altitude in sunrise is deg degries. This function only works for altitudes the sun realy is. If the sun never gets to this altitude, the returned sunset and sunrise values will be negative. That can happen at low altitude when latitude is nearing the pols in winter times β the sun never goes very high in the sky there, fr.
Parameters:
dayβ this day of month.monthβ this month.yearβ this year.longitudeβ longitude to use in calculations.latitudeβ latitude to use in calculations.degβ degrees of sun's altitude (0- Zenith ..90- Horizon).sunriseβ return the utc sunrise in minutes.sunsetβ return the utc sunset in minutes.
void hdate_get_utc_sun_time (int day, int month, int year, double latitude, double longitude, int *sunrise, int *sunset)
UTC sunrise/set time for a gregorian date βοΈ.
Parameters:
dayβ this day of month.monthβ this month.yearβ this year.longitudeβ longitude to use in calculations degrees, negative values are east.latitudeβ latitude to use in calculations degrees, negative values are south.sunriseβ return the utc sunrise in minutes after midnight (00:00).sunsetβ return the utc sunset in minutes after midnight (00:00).
void hdate_get_utc_sun_time_full (int day, int month, int year, double latitude, double longitude, int *sun_hour, int *first_light, int *talit, int *sunrise, int *midday, int *sunset, int *first_stars, int *three_stars)
UTC sunrise/set time for a gregorian date β the full deluxe package π.
Parameters:
dayβ this day of month.monthβ this month.yearβ this year.longitudeβ longitude to use in calculations.latitudeβ latitude to use in calculations.sun_hourβ return the length of shaa zaminit in minutes.first_lightβ return the utc alut ha-shachar in minutes.talitβ return the utc tphilin and talit in minutes.sunriseβ return the utc sunrise in minutes.middayβ return the utc midday in minutes.sunsetβ return the utc sunset in minutes.first_starsβ return the utc tzeit hacochavim in minutes.three_starsβ return the utc shlosha cochavim in minutes.
int hdate_get_gday (hdate_struct const *h)
Get the Gregorian day of the month.
hβ pointer thishdatestruct.
Returns: the Gregorian day of the month, 1..31.
int hdate_get_gmonth (hdate_struct const *h)
Get the Gregorian month.
hβ pointer thishdatestruct.
Returns: the Gregorian month, jan = 1.
int hdate_get_gyear (hdate_struct const *h)
Get the Gregorian year.
hβ pointer thishdatestruct.
Returns: the Gregorian year.
int hdate_get_hday (hdate_struct const *h)
Get the Hebrew day of the month.
hβ pointer thishdatestruct.
Returns: the Hebrew day of the month, 1..30.
int hdate_get_hmonth (hdate_struct const *h)
Get the Hebrew month.
hβ pointer thishdatestruct.
Returns: the Hebrew month, Tishery = 1 .. Adar I = 13, Adar II = 14.
int hdate_get_hyear (hdate_struct const *h)
Get the Hebrew year.
hβ pointer thishdatestruct.
Returns: the Hebrew year.
int hdate_get_day_of_the_week (hdate_struct const *h)
Get the day of the week π.
hβ pointer thishdatestruct.
Returns: the the day of the week.
int hdate_get_size_of_year (hdate_struct const *h)
Get the size of the hebrew year.
hβ pointer thishdatestruct.
Returns: the the size of the hebrew year.
int hdate_get_new_year_day_of_the_week (hdate_struct const *h)
Get the new year day of the week π.
hβ pointer thishdatestruct.
Returns: the the new year day of the week.
int hdate_get_julian (hdate_struct const *h)
Get the Julian day number.
hβ pointer thishdatestruct.
Returns: the Julian day number.
int hdate_get_days (hdate_struct const *h)
Get the number of days passed since 1 tishrey.
hβ pointer thishdatestruct.
Returns: the number of days passed since 1 tishrey.
int hdate_get_weeks (hdate_struct const *h)
Get the number of weeks passed since 1 tishrey π¦.
hβ pointer thishdatestruct.
Returns: the number of weeks passed since 1 tishrey.
π« hdate_struct* new_hdate ()
okay so bestie, this is the glow-up moment β it creates a brand-new hdate struct object β¨. And like, listen: it's not set-and-forget. You gotta delete_hdate it when you're done, no cap, or you're just leaving your memory lying around like laundry on the floor π.
Returns: a new hdate object π
ποΈ hdate_struct* delete_hdate (hdate_struct *h)
the cleanup era π
this one deletes an hdate struct object. bye bestie, you served π«Ά
Parameters:
hβ pointer this hdate struct.
π·οΈ char* hdate_get_version_string ()
gives you a static string with the package name and the version. it's giving name-tag energy π
Returns: a static string, with the package name and version β
π char* hdate_get_translator_string ()
the name of the translator, iconic behavior honestly π
Returns: a static string with name of translator, or NULL if none.
π΅οΈββοΈ int hdate_is_hebrew_locale ()
a little helper function that goes snooping around to find out if you're in a hebrew locale. lowkey useful, highkey underrated π
Returns:
0β latin locale-1β hebrew locale
π char* hdate_string (inttype_of_string, intindex, intshort_form, inthebrew_form)
this one returns string values for hdate info β it's the main character of this whole page fr fr π₯
Returns: a pointer to a string containing the information. but bestie, heads up β οΈ: in the cases integers and omer, the strings will NOT be static, and the caller must free() them after use. Returns a null pointer upon failure.
Parameters:
type_of_stringβ0= integer,1= day of week,2= parshaot,3= hmonth,4= gmonth,5= holiday,6= omerindexβ integer (0 < n < 11000) day of week (0 < n < 8) parshaot (0 , n < 62) hmonth (0 < n < 15) gmonth (0 < n < 13) holiday (0 < n < 37) omer (0 < n < 50)short_formβ0= short formathebrew_formβ0= not hebrew (native/embedded)
βοΈ Author βοΈ
Generated automatically by Doxygen for libhdate C language from the source code. yeah, the robots did the typing, we just did the vibes π§
and that's the whole page bestie, we ate and left no crumbs π this was Version 1.4, dated Sun Jan 8 2012, living in src/hdate.h(3) π mwah, go compile something cute π
β¨
π¦ where this page comes from
- debian bookworm: libhdate-dev 1.6.02-2.1+b3 Β· GPL-3.0-or-later
- debian trixie: libhdate-dev 1.6.02-2.1+b8 Β· GPL-3.0-or-later
- ubuntu jammy: libhdate-dev 1.6.02-2.1build1 Β· GPL-3.0-or-later
- ubuntu noble: libhdate-dev 1.6.02-2.1build5 Β· GPL-3.0-or-later
- ubuntu questing: libhdate-dev 1.6.02-2.1build6
- ubuntu resolute: libhdate-dev 1.6.02-2.1build7 Β· GPL-3.0-or-later
- ubuntu stonking: libhdate-dev 1.6.02-2.1build8 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms