Calculating Erev Pesach Zmanim

MatzosThe Zmanim API did not have dedicated zmanim to calculate the Erev Pesach zmanim of sof zman achilas chametz (the latest time one can eat chametz), and sof zman biur chametz (the latest time to burn chametz) till the April 14 check in to the KosherJava Zmanim Project GitHub repository. The latest time for eating chametz is at the end of the fourth hour of the day. This corresponds to sof zman tfila. The API has about 12 of those, so that does not require any special programming, but to help developers who are unaware of how they work I created three wrapper getSofZmanAchilasChametz methods (getSofZmanAchilasChametzGRA(), getSofZmanAchilasChametzMGA72Minutes() and getSofZmanAchilasChametzMGA​16Point1Degrees()) calling the three most commonly used getSofZmanTfila methods (getSofZmanTfilaGRA(), getSofZmanTfilaMGA72Minutes() and getSofZmanTfilaMGA​16Point1Degrees()).

Note: The code samples below have been updated for the KosherJava Zmanim 3.x API. In the current API, the Erev Pesach methods return null on any day other than Erev Pesach.

For example, here is the current code used in getSofZmanAchilasChametzGRA():

public Instant getSofZmanAchilasChametzGRA() {
	return getSofZmanAchilasChametz(getSunriseBasedOnElevationSetting(), getSunsetBasedOnElevationSetting(), true);
}

The API itself is very flexible, and as long as you know the calculation of the zman, you can easily calculate it. For example, to calculate sof zman biur chametz according to the GRA, the time would be 5 shaos zmaniyos after sunrise. Using the Zmanim API this would be coded as:

Instant sofZmanBiurChametzGra = getTimeOffset(getSeaLevelSunrise(), getTemporalHour().multipliedBy(5));

The current code used in the API is:

public Instant getSofZmanBiurChametzGRA() {
	return getSofZmanBiurChametz(getSunriseBasedOnElevationSetting(), getSunsetBasedOnElevationSetting(), true);
}

Developers who want to use the current API to generate these zmanim can use the following sample as a guide.

String locationName = "Lakewood, NJ";
double latitude = 40.09596; // Lakewood, NJ
double longitude = -74.22213; // Lakewood, NJ
double elevation = 0; // optional elevation
ZoneId timeZone = ZoneId.of("America/New_York");
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ComprehensiveZmanimCalendar czc = new ComprehensiveZmanimCalendar(location);
czc.setLocalDate(LocalDate.of(2011, Month.APRIL, 18)); // Erev Pesach 5771
DateTimeFormatter tf = DateTimeFormatter.ofPattern("EEE MMM d h:mm:ss a z yyyy").withZone(timeZone);
System.out.println("Erev Pesach Zmanim for " + locationName);
System.out.println("Sof Zman Achilas Chametz GRA: " + tf.format(czc.getSofZmanAchilasChametzGRA()));
System.out.println("Sof Zman Biur Chametz GRA: " + tf.format(czc.getSofZmanBiurChametzGRA()));
System.out.println("Sof Zman Achilas Chametz MGA 72 Minutes: " + tf.format(czc.getSofZmanAchilasChametzMGA72Minutes()));
System.out.println("Sof Zman Biur Chametz MGA 72 Minutes: " + tf.format(czc.getSofZmanBiurChametzMGA72Minutes()));
System.out.println("Sof Zman Achilas Chametz MGA 16.1 Deg: " + tf.format(czc.getSofZmanAchilasChametzMGA16Point1Degrees()));
System.out.println("Sof Zman Biur Chametz MGA 16.1 Deg: " + tf.format(czc.getSofZmanBiurChametzMGA16Point1Degrees()));

This would output:

Erev Pesach Zmanim for Lakewood, NJ
Sof Zman Achilas Chametz GRA: Mon Apr 18 10:42:42 AM EDT 2011
Sof Zman Biur Chametz GRA: Mon Apr 18 11:49:39 AM EDT 2011
Sof Zman Achilas Chametz MGA 72 Minutes: Mon Apr 18 10:18:42 AM EDT 2011
Sof Zman Biur Chametz MGA 72 Minutes: Mon Apr 18 11:37:39 AM EDT 2011
Sof Zman Achilas Chametz MGA 16.1 Deg: Mon Apr 18 10:14:02 AM EDT 2011
Sof Zman Biur Chametz MGA 16.1 Deg: Mon Apr 18 11:35:24 AM EDT 2011

Zmanim API Now in a Public SVN Server

Cyber VaultThanks to Jay Gindin, the Zmanim API source code is now on a publicly available SVN server. The Google Code project can be found at code.google.com/p/kosherjava. This will have a number of benefits to the project. It will more easily allow users to find the code, ensure that they have the latest code, track changes, and allow reverting to prior versions in case an issue arises with newly checked-in code. It will also allow me to stop the manual backups (part of the project’s Ant build script) done as part of every development build. The repository has the new hebrewcalendar package mentioned in the recently posted FAQ: How do I Calculate the Jewish/Hebrew Date for …?. This new code is under heavy revision, and there will be changes that will likely break code using the current alpha version. The interface will likely stabilize once the first beta version is released (probably after Pesach). The next step will be to touch base with various people who have copies of the API in their own SVN to either update or link to this official project SVN server.

KosherJava Zmanim Code Now on GitHub

With Google shutting down Google Code at the end of 2015, the KosherJava Zmanim source code has been moved to GitHub.

FAQ: How do I Calculate the Jewish/Hebrew Date for …?

Sunrise Calendar

Note: This FAQ is now obsolete. Jewish calendar calculations are now supported. See the Zmanim API 1.3.0 release announcement.

Question:

How do I get the Jewish date for … using the Zmanim API?

Answer:

The current version of the Zmanim API does not support Jewish calendrical calculations. Zmanim are almost exclusively based on the solar calendar, so for example, the sunrise on February 8th this year in Montreal (or any other date and location) will be almost the same every year. For this reason there was little point (as far as zmanim) to support Jewish date calculations in the API. One of the only zmanim to rely on a Jewish date is the sof zman Kiddush Levana calculation, though there are some opinions that it is purely molad based, and this can be calculated without a Jewish calendar component to the API. This zman is obviously not currently implemented in the Zmanim API. I am currently working on adding Jewish date support to the API. The code is based on Avrom Finkelstein‘s no longer active HebrewDate project. I refactored a lot of the code and fixed a number of bugs. Anyone interested in alpha testing this code can download the latest Zmanim code.

I mentioned that it “will be almost the same every year” and this is due to the approximate 1/4 day drift between the 365-day calendar year and the approximately 365.25 days actually present in the astronomical year, a discrepancy corrected every leap year. A future FAQ (probably a few of them) may delve specifically into this drift as well as general zmanim accuracy issues in detail.

If you are simply looking to convert a Hebrew date to Gregorian or Gregorian to Hebrew online without the API, try the JewishGen calendar conversion tools.

New release of the Hebrew Date Plugin for WordPress

WordPress coffee mug

Note: The Hebrew Date plugin described in this post is no longer supported or available. Please use the WP Hebrew Date plugin by hatul instead.

Mike, who took over development of the WordPress Hebrew Date plugin in 2006, released a new version of the plugin. The WordPress Hebrew Date plugin is now hosted at the WordPress plugin repository. This should make it easier for people to find and update the plugin. New in this version is support for the WordPress 3.0 default theme, a general rewrite, and expansion of the API calls intercepted by the plugin. See the changelog page for a more detailed list of all the changes. Please contact Mike with any suggestions, comments or bugs.