Hebrew/Jewish Date Class (1 Viewer)

Status
Not open for further replies.

ozinm

Human Coffee Siphon
Local time
Today, 11:43
Joined
Jul 10, 2003
Messages
121
Updated on 3rd Feb 2012 with new version of code (attached)
Here's a Hebrew date class I've been recently building.
It performs direct conversion between Hebrew and Gregorian dates, Yahrzeit calculations and GUI Hebrew Date Picker dialog box.

The file is is Access 2010 format and contains an example form to demonstrate some of the functionality.

I'd love to hear any feedback you my have on it.
PM me on this board or contact me via my blog: marcozin.blogspot.com

Here's a list of the functionality with some description...

Code:
  clsHebrewDate Class
  PROPERTIES
    .HDay
        Read/Write (long)
        stores the value of the current Hebrew day
        When set, the Gregorian Date will automatically be updated.
    .HMonth
        Read/Write (long)
        stores the value of the current Hebrew month
        When set, the Gregorian Date will automatically be updated.
    .HYear
        Read/Write (long)
        stores the value of the current Hebrew year
        When set, the Gregorian Date will automatically be updated.
    .HDaysInMonth
        Read Only (integer)
        returns the number of days in current Hebrew month.
    .GDate
        Read/Write (date)
        stores the value of the current Gregorian Date
        When set, the Hebrew Date will automatically be updated.
    .GAfterSunset
        Read/Write (boolean)
        used to mark the Gregorian date as occuring after sunset.
        NB: Gregorian days start at midnight but Hebrew days start
        after sunset
        TRUE = After sunset
        FALSE = Before sunset
        When set, the Hebrew Date will automatically be updated.
    .IsHLeapyear
        Read Only (boolean)
        Returns TRUE if the current Hebrew Year is a Hebrew leapyear
        NB: Hebrew leap years include a whole extra month (Adar II)
        and occur in a pattern that follows a 19 year cycle (see below)
    .IsValid
        Read Only (boolean)
        Returns TRUE if the current Hebrew Date is valid
  METHODS
    .Copy()
        Function returns clsHebrewDate type
        Creates and returns a new copy of the current instance
        of the clsHebrewDate class.
    .SetHebrewDate(<HebrewDate>)
        Sets the Hebrew date and automatically updates the Gregorian
        date.
    .YahrzeitStep(<YearStep>[,<CalcStyle>])
        Alters the current Hebrew Date moving it forward or backward
        x years according to the value of YearStep in accordance with
        the selected algorithm selected by CalcStyle.
        NB: You should always calculate additional Yahrzeit dates from
        the orginal date of the aneversary. DO NOT be tempted to calc
        a Yahrzeit from a previous Yahrzeit! This will lead to errors!
        YearStep: integer value can be positive or negative
        CalcStyle: (OPTIONAL)
                    1: Traditional (DEFAULT)
                    2: Reform
                    3: CatchAll

Module modHebrewDate
Function's
	GetHebrewMonthsList(bLeapYear As Boolean) As Variant
		returns a list of month numbers and their names delimited with semicolons
		this is particularly useful for generating combobox dropdown lists
		NB: Hebrew leap years have a extra month, hence the need for bLeapYear 
		to specify if the list should generate months for a leap year

	FormatHDate(myDate As clsHebrewDate, myFormat As Variant) As Variant
		Format hebrew date and output as a variant string.
		Variant string is needed so unicode letters can be used i.e. for Hebrew text
		the format parameters are based on the ones uses in PHP. See http://php.net/manual/en/function.date.php
		Format codes:
			Misc
				\	escape character
			Day
                d	Date, 2 digits with leading zeros (00..30)
                f	Textual representation of date as stored in the language table (HDate01..HDate30)
                j	Date as number without leading zeros (1..30)
                l	NB: this is a lowercase letter L
					Textual representation of the day of the week as stored in the language table (HDay1..HDay7)
                S	English ordinal suffix for the day of the month, 2 characters (st, nd, rd, th)
                w	returns 1..7 where 1=Sunday (Yom Rishon)
			Month
                F	Textual representation of a month as stored in the language table
					(HMonth01..05, HMonth07..13, HMonth06Leap, HMonth07Leap)
                m	Numeric representation of a month, with leading zeros (01..13)
                n	Numeric representation of a month, without leading zeros (1..13)
                t	Number of days in the given month (29..30)
			Year
                L	Whether it's a leap year (1=yes 0=no)
                Y	A full numeric representation of a year, all digits (eg 5758)
                y	A two digit representation of a year (eg 58)
			Time
                a	Textual representation of time of day in the Gregorian Date part as stored in Language Table (GTimeNight, GTimeDay)
Sub's
	SetHebrewDateFromGUI(ByRef MyHebrewDate As clsHebrewDate)
		Shows a hebrew date picker dialog box and returns any selected date back to the carable passed to MyHebrewDate
		NB: if you prefer the dialog box to display in Right to Left mode and have days that change according to the hebrew
		rather than the gregorian calendar (i.e. at sunset rather than midnight) edit the dlgHebDatePick13/14 form and set
		Const CDisplayRTL = True
 

Attachments

  • hebrewDates.2012.02.03.01.accdb
    716 KB · Views: 1,150
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom