import math


def jd_to_gregorian(jd):
	"""Return Gregorian or Julian date of Julian Day

	Negative Julian Day < -0.5 is not supported.

	Return:
	int - year
	int - month [1..12]
	int - day [1..31]
	"""
	if jd < -0.5: raise ValueError('Julian Day < -0.5 is not supported')

	jd1 = jd + 0.5
	z = math.floor(jd1)
	f = jd1 - z
	if z < 2299161:
		a = z
	else:
		aa = math.floor((z - 1867216.25) / 36524.25)
		a = z + 1 + aa - math.floor(aa / 4.0)
	b = a + 1524
	c = math.floor((b - 122.1) / 365.25)
	d = math.floor(365.25 * c)
	e = math.floor((b - d) / 30.6001)
	day = b - d - math.floor(30.6001 * e) + f
	month = e - 1 if e < 14 else e - 13
	year = c - 4715 if month <= 2 else c - 4716
	return (int(year), int(month), int(day))