def solar_term(self, year, degrees, timezone='<STR_LIT>'):
twopi = <NUM_LIT:2> * pi<EOL>tz = pytz.timezone(timezone)<EOL>sun = ephem.Sun(ephem.Date(str(year)))<EOL>current_longitude = sun.hlong - pi<EOL>target_longitude = degrees * ephem.degree<EOL>difference = (target_longitude - current_longitude) % twopi<EOL>t0 = ephem.Date(str(year)) + <NUM_LIT> * difference / twopi<EOL>def f(t):<EOL><INDENT>sun.compute(t)<EOL>longitude = sun.hlong - pi<EOL>return ephem.degrees(target_longitude - longitude).znorm<EOL><DEDENT>d = ephem.Date(ephem.newton(f, t0, t0 + ephem.minute))<EOL>solar_term = d.datetime() + tz.utcoffset(d.datetime())<EOL>return solar_term.date()<EOL>
Returns the date of the solar term for the given longitude
and the given year.

Solar terms are used for Chinese and Taiwanese holidays
(e.g. Qingming Festival in Taiwan).

More information:
- https://en.wikipedia.org/wiki/Solar_term
- https://en.wikipedia.org/wiki/Qingming

This function is adapted from the following topic:
https://answers.launchpad.net/pyephem/+question/110832