Hebcal uses the algorithm defined in Calendrical Calculations by Edward M. Reingold and Nachum Dershowitz.
Reingold and Dershowitz write:
The birthday of someone born in Adar of an ordinary year or Adar II of a leap year is also always in the last month of the year, be that Adar or Adar II. The birthday in an ordinary year of someone born during the first 29 days of Adar I in a leap year is on the corresponding day of Adar; in a leap year, the birthday occurs in Adar I, as expected. Someone born on the thirtieth day of Marcheshvan, Kislev, or Adar I has his birthday postponed until the first of the following month in years where that day does not occur. [Calendrical Calculations p. 111]
The rule for a Yahrzeit is a little different:
The customary anniversary date of a death is more complicated and depends also on the character of the year in which the first anniversary occurs. There are several cases:
- If the date of death is Marcheshvan 30, the anniversary in general depends on the first anniversary; if that first anniversary was not Marcheshvan 30, use the day before Kislev 1.
- If the date of death is Kislev 30, the anniverary in general again depends on the first anniverary — if that was not Kislev 30, use the day before Tevet 1.
- If the date of death is Adar II, the anniversary is the same day in the last month of the Hebrew year (Adar or Adar II).
- If the date of death is Adar I 30, the anniversary in a Hebrew year that is not a leap year (in which Adar only has 29 days) is the last day in Shevat.
- In all other cases, use the normal (that is, same month number) anniverary of the date of death.
[Calendrical Calculations p. 113]
For example, suppose Ploni ben Ploni passed away on 14 March 2001. That date corresponds to the 19th of Adar, 5761. Since 5761 was not a leap year, there was only one Adar that year (i.e. the date of death occurred in 12th month of the Hebrew year).
Suppose one wishes to observe the yahrzeit in Hebrew year 5765. Since 5765 is a leap year and none of the other rules applies, we use the same month number as the date of death. In a leap year the 12th month is Adar I, so the yahrzeit is observed on 19th of Adar I, 5765 (28 February 2005).
On page 114, Reingold and Dershowitz write:
There are minor variations in custom regarding the anniversary date in some of these cases. For example, Spanish and Portuguese Jews never observe the anniversary of a common-year date in Adar I.
There are undoubtedly many differing opinions regarding when to observe an Adar yahrzeit.
Here are two articles which offer differing opinions from our implementation:
For all matters of halacha, consult your local rabbi.
9 Feb 2005: added errata at Nachum Dershowitz’s request.
9 Mar 2005: Added Ploni ben Ploni example.
9 Mar 2014: Added links to opinions by Rabbis Golinkin and Schachter