How do I get the Jewish Date for … using the Zmanim API?
Answer:
The current version of the Zanim 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 kidush levanah 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 off 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 SVN code. I mentioned that it “will be almost the same every year” and this is due the approximate 1/4 day drift between the 356 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 JewishGencalendar conversion tools.
As mentioned briefly in the “Why Some Zmanim Never Occur” post, the Lubavitch Jewish Center of Anchorage, Alaska has an interesting davening (prayer) direction question. As explained in the “Bearing to Yerushalayim and Zmanim Map” (additional technical information is available in the “Technical Information about the Bearing to Yerushalayim Map” post), there are two opinions about the proper direction to face during Tfilah (prayers). The Levush and others are of the opinion that one should face the rhumb line direction to Yerushalayim, while the Emunas Chachamim and others are of the opinion that one should face the initial bearing of the great circle route. Both of these opinions would clearly use the shortest rhumb or great circle lines to Yerushalayim. As an example, a person standing on Har Hazaisim (Mount of Olives) a mile east of Har Habayis would not daven east using the logic that continuing east for approximately 21,175 miles[1] would reach Yerushalayim via global circumnavigation, when Har Habayis is just one mile to the west. The shul in Anchorage is located at a longitude of -149.861°. The antipode of Har Habayis is on the -144.764851 longitude line – 180° of longitude from Har Habayis. People on different sides of this line (this line is also the halachic dateline according to Rav Yechiel Michel Tucazinsky and others) will daven in opposite directions. The Anchorage shul with a longitude of -149.861° is 169.69 miles (273.1 km) west of the -144.764851° longitude line[2]. For this reason, the shul should daven not east, but west (255.78° from the north, or slightly south-west) if using the common rhumb line calculation, or north (355.67° from the north, or slightly west of north) if using the great circle calculation. Alaska is the only location in the world that has the -144.764851° longitude line cut across dry land, and is therefore the only non-ocean location to face this issue.
Notes: 1. Based on a rhumb line along the 31° 50′circle of latitude as opposed to 24,901 miles at the equator) using a WGS84Reference ellipsoid. 2. Rhumb line calculation as calculated by Movable Type using the same latitude for both points. The ellipsoidal shape of the earth is factored into this calculation. The short distance means that the 169.66 mi (272.98 km) great circle distance is very close to the rhumb line distance.
Why do some zmanim never occur in some locations? Developers Beware!
Answer:
While most people realize that the sun may not rise or set in the Arctic and Antarctic Circles (see the Rabbi Dovid Heber’s article When Does One Pray When There Is No Day in the Star-K’s Kashrus Kurrents), many are not aware that some twilight dips will not occur during part of the year as far south of the Arctic Circle as London. For example around the summer solstice in London (on the zmanim map) the sun will never dip far enough below the horizon to reach alos 16°. This happens in London from June 4th through July 8th. The image seen on the top right (original at timeanddate.com) shows various civil twilights centered on London on Midnight June 21st. Look carefully to see the various bands of twilight. Gateshead will not have alos 16° from May 16th through July 28th, while Anchorage, Alaska (yes there is a Frum Shul in Anchorage with an interesting davening direction issue that is discussed in the Davening Direction from Alaska post ) will not have alos 16.1° from April 25th to August 20th. Zmanim based on sunrise such as alos 72 that is a 72 minute offset of sunrise can be calculated as long as sunrise can be calculated, something that will happen as long as you are not in the Arctic or Antarctic Circles. For this reason, the Zmanim API will return a null when a zman will not happen. A Long.MIN_VALUE will be returned when a long is expected such as in the case of a shaah zmanis. While an inconvenience to developers who have to code for this, the alternative of a default date would mean that developers unaware of this would return incorrect zmanim, something far worse than a program error from a NullPointerException. In recent weeks two publicly available programs using the Zmanim API ran into issues due to nulls returned for early alos times. Being something not anticipated by the developers, the nulls generated errors in the programs that quickly led to fixes. For this reason, Yitzchok updated the Zmanim .NET project to return the nullable DateTime? instead of the regular DateTime that it had previously been returning. While the Zmanim API documentation always made the possibility of a null being returned possible, I modified the documentation to make this clear on the return value documentation for every zman. Code with the modified documentation was part of the recently released Zmanim API 1.2.1.
The Zmanim API 1.2.1 was released today. Changed in this release were the addition of a few very early Tzais zmanim, and the removal of references to the GregorianCalendar in favor of the base Calendar class to ease Noah Blumenthal’s use of the Zmanim API in a zmanim application for the BlackBerry. This change has no impact on functionality as tested using Yitzchok’s new JUnit tests. Additionally, the JavaDoc Zmanim API documentation was modified to clearly indicate that zmanim can return nulls. A followup post will have details on this. The main download is the Zmanim 1.2.1 release zip file that includes source files and JavaDoc documentation. Also available for download (included in the above zip file) is the main zmanim-1.2.1.jar and the zmanimAstronomical-1.2.1.jar that only includes the AstronomicalCalendar. The removal of the GregorianCalendar was in this class. Additional detail on the downloads can be seen on the Zmanim Download page
Yitzchok ported the Zmanim API from Java to a .NET API using C#. The Zmanim .NET project was released under the LGPL 2.1. This is a change from the GPL used by the Java API, something that may change shortly. Also part of the project was the creation of a C# version of the Zmanim CLI, matching Moshe Wagner’sJava Zmanim CLI. When developing the project, Yitzchok created the ZmanimTestJUnit test case class to confirm that the C# port output matched the Java API. I will likely add this to the core Zmanim API in the near future. The port currently relies on IKVM assemblies as can be seen in the Java references in the code sample below, mostly because of the lack of a native .NET equivalent of the Java TimeZone class. Yitzchok also created some examples of the use of the Zmanim .NET API that will be of help to developers. Below are two of the simpler examples in C# and VB.NET demonstrating a very simple use of the API to output zmanim from the console.
C#
using Zmanim.TimeZone;
using Zmanim.TzDatebase; //in Zmanim.TzDatebase.dll assembly
using Zmanim.Utilities;
namespace Zmanim.Samples.Console
{
class Program
{
static void Main(string[] args)
{
string locationName = "Lakewood, NJ";
double latitude = 40.09596; //Lakewood, NJ
double longitude = -74.22213; //Lakewood, NJ
double elevation = 0; //optional elevation
ITimeZone timeZone = new OlsonTimeZone("America/New_York");
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ComplexZmanimCalendar zc = new ComplexZmanimCalendar(location);
//optionally set it to a specific date with a year, month and day
//ComplexZmanimCalendar zc = new ComplexZmanimCalendar(new DateTime(1969, 2, 8), location);
System.Console.WriteLine("Today's Zmanim for " + locationName);
System.Console.WriteLine("Sunrise: " + zc.GetSunrise()); //output sunrise
System.Console.WriteLine("Sof Zman Shema MGA: " + zc.GetSofZmanShmaMGA()); //output Sof Zman Shema MGA
System.Console.WriteLine("Sof Zman Shema GRA: " + zc.GetSofZmanShmaGRA()); //output Sof Zman Shema GRA
System.Console.WriteLine("Sunset: " + zc.GetSunset()); //output sunset
System.Console.WriteLine("Press enter to exit.");
System.Console.ReadLine();
}
}
}
VB.NET
mports Zmanim.TzDatebase 'in Zmanim.TzDatebase.dll assembly
Imports Zmanim.Utilities
Imports Zmanim.TimeZone
Module Module1
Sub Main()
Dim locationName As String = "Lakewood, NJ"
Dim latitude As Double = 40.09596 'Lakewood, NJ
Dim longitude As Double = -74.22213 'Lakewood, NJ
Dim elevation As Double = 0 'optional elevation
Dim timeZone As ITimeZone = New OlsonTimeZone("America/New_York")
Dim location As New GeoLocation(locationName, latitude, longitude, elevation, timeZone)
Dim zc As New ComplexZmanimCalendar(location)
'optionally set it to a specific date with a year, month and day
'Dim zc As New ComplexZmanimCalendar(New DateTime(1969, 2, 8), location)
System.Console.WriteLine("Today's Zmanim for " & locationName)
System.Console.WriteLine("Sunrise: " & zc.GetSunrise().ToString)
'output sunrise
System.Console.WriteLine("Sof Zman Shema MGA: " & zc.GetSofZmanShmaMGA().ToString)
'output Sof Zman Shema MGA
System.Console.WriteLine("Sof Zman Shema GRA: " & zc.GetSofZmanShmaGRA().ToString)
'output Sof Zman Shema GRA
System.Console.WriteLine("Sunset: " & zc.GetSunset().ToString)
'output sunset
System.Console.WriteLine("Press enter to exit.")
System.Console.ReadLine()
End Sub
End Module
The current Zmanim .NET TODO list for the project includes: