Shana tova umetuka! (Happy Jewish New Year!) Write the shortest program, in the language of your choice, that takes as input a year on the Hebrew calendar, and outputs the corresponding Gregorian date for Rosh Hashana, in YYYY-MM-DD format.

~$ rh 5771
2010-09-09
~$ rh 5772
2011-09-29
~$ rh 5773
2012-09-17



The input may come from either the command line or from stdin, whichever is more convenient.
You may assume that the year will be between 5600 (1839) and 6000 (2239), inclusive.
Ruby, 192 181 165 characters
require'date'
s=(-6+235*n=gets.to_i)/19*765433+73848;e=s/u=25920
$&gt;&lt;&lt;Date.jd(347641+e+([h=s%u/19440,84&gt;&gt;e%7+h&amp;1,v=e%7*(374454&gt;&gt;n%19&amp;1-h&amp;s%u/9923),v,n-5765].count 1))

Input is given as a single number on STDIN.
Edit 1: Several arithmetic transformations saved quite a few characters.
Edit 2: There was some room for improvement.