Create a new date from a Julian date.
@memberof GregorianCalendar
@param jd {number} The Julian date to convert.
@return {CDate} The equivalent date.
546782
function(jd) {
			// Jean Meeus algorithm, "Astronomical Algorithms", 1991
			var z = Math.floor(jd + 0.5);
			var a = Math.floor((z - 1867216.25) / 36524.25);
			a = z + 1 + a - Math.floor(a / 4);
			var b = a + 1524;
			var c = Math.floor((b - 122.1) / 365.25);
			var d = Math.floor(365.25 * c);
			var e = Math.floor((b - d) / 30.6001);
			var day = b - d - Math.floor(e * 30.6001);
			var month = e - (e > 13.5 ? 13 : 1);
			var year = c - (month > 2.5 ? 4716 : 4715);
			if (year <= 0) { year--; } // No year zero
			return this.newDate(year, month, day);
		}
27199
function(jd) {
			jd -= this.jdEpoch;
			var day = mod(jd + 8 + ((18 - 1) * 20), 365);
			return [Math.floor(day / 20) + 1, mod(day, 20)];
		}
429759
def hdate_to_jdn(date):
    
    day = date.day
    month = date.month
    if date.month == 13:
        month = 6
    if date.month == 14:
        month = 6
        day += 30

    # Calculate days since 1,1,3744
    day = _days_from_3744(date.year) + (59 * (month - 1) + 1) // 2 + day

    # length of year
    length_of_year = get_size_of_hebrew_year(date.year)
    # Special cases for this year
    if length_of_year % 10 > 4 and month > 2:  # long Heshvan
        day += 1
    if length_of_year % 10 < 4 and month > 3:  # short Kislev
        day -= 1
    if length_of_year > 365 and month > 6:  # leap year
        day += 30

    # adjust to julian
    return day + 1715118
759553
def from_jd(jd):
    ''''''
    year = gregorian.from_jd(jd)[0]
    day = jwday(jd) + 1

    dayofyear = ordinal.from_jd(jd)[1]
    week = trunc((dayofyear - day + 10) / 7)

    # Reset year
    if week < 1:
        week = weeks_per_year(year - 1)
        year = year - 1

    # Check that year actually has 53 weeks
    elif week == 53 and weeks_per_year(year) != 53:
        week = 1
        year = year + 1

    return year, week, day
935474
public static java.util.Date toJavaUtilDate(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    cal.set(date.year, date.month - 1, date.dayOfMonth);
    return cal.getTime();
  }
646550
def calendar_date(jd_integer):
    """"""

    k = jd_integer + 68569
    n = 4 * k // 146097

    k = k - (146097 * n + 3) // 4
    m = 4000 * (k + 1) // 1461001
    k = k - 1461 * m // 4 + 31
    month = 80 * k // 2447
    day = k - 2447 * month // 80
    k = month // 11

    month = month + 2 - 12 * k
    year = 100 * (n - 49) + m + k

    return year, month, day
25019
function LunarDate (dd, mm, yy, leap, jd) {
  this.day = dd
  this.month = mm
  this.year = yy
  this.leap = leap
  this.jd = jd
}
748441
def jdFromDate(dd, mm, yy):
    ''''''
    a = int((14 - mm) / 12.)
    y = yy + 4800 - a
    m = mm + 12 * a - 3
    jd = dd + int((153 * m + 2) / 5.) \
        + 365 * y + int(y / 4.) - int(y / 100.) \
        + int(y / 400.) - 32045
    if (jd < 2299161):
        jd = dd + int((153 * m + 2) / 5.) \
            + 365 * y + int(y / 4.) - 32083
    return jd
85782
def _from_jd_equinox(jd):
    ''''''
    jd = trunc(jd) + 0.5
    equinoxe = premier_da_la_annee(jd)

    an = gregorian.from_jd(equinoxe)[0] - YEAR_EPOCH
    mois = trunc((jd - equinoxe) / 30.) + 1
    jour = int((jd - equinoxe) % 30) + 1

    return (an, mois, jour)
624224
public static Date dateIncreaseByDay(Date date, int days) {

        Calendar cal = GregorianCalendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.DATE, days);

        return cal.getTime();
    }
598036
def gdate_to_jdn(date):
    
    not_jan_or_feb = (14 - date.month) // 12
    year_since_4800bc = date.year + 4800 - not_jan_or_feb
    month_since_4800bc = date.month + 12 * not_jan_or_feb - 3
    jdn = date.day + (153 * month_since_4800bc + 2) // 5 \
        + 365 * year_since_4800bc \
        + (year_since_4800bc // 4 - year_since_4800bc // 100 +
           year_since_4800bc // 400) - 32045
    return jdn
1130083
def jdn_to_gdate(jdn):
    
    # pylint: disable=invalid-name

    # The algorithm is a verbatim copy from Peter Meyer's article
    # No explanation in the article is given for the variables
    # Hence the exceptions for pylint and for flake8 (E741)

    l = jdn + 68569  # noqa: E741
    n = (4 * l) // 146097
    l = l - (146097 * n + 3) // 4  # noqa: E741
    i = (4000 * (l + 1)) // 1461001  # that's 1,461,001
    l = l - (1461 * i) // 4 + 31  # noqa: E741
    j = (80 * l) // 2447
    day = l - (2447 * j) // 80
    l = j // 11  # noqa: E741
    month = j + 2 - (12 * l)
    year = 100 * (n - 49) + i + l  # that's a lower-case L

    return datetime.date(year, month, day)
1021777
public static CharSequence getJSDate(Calendar calendar)
	{
		StringBuilder dateJavascript = new StringBuilder();
		dateJavascript.append("new Date(");
		dateJavascript.append(calendar.get(Calendar.YEAR)).append(',');
		dateJavascript.append(calendar.get(Calendar.MONTH)).append(',');
		dateJavascript.append(calendar.get(Calendar.DAY_OF_MONTH)).append(',');
		dateJavascript.append(calendar.get(Calendar.HOUR_OF_DAY)).append(',');
		dateJavascript.append(calendar.get(Calendar.MINUTE)).append(',');
		dateJavascript.append(calendar.get(Calendar.SECOND)).append(',');
		dateJavascript.append(calendar.get(Calendar.MILLISECOND));
		dateJavascript.append(')');

		return dateJavascript.toString();
	}
788618
def to_jd(year, month, day):
    ''''''

    legal_date(year, month, day)

    # Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61

    if month <= 2:
        year -= 1
        month += 12

    return (trunc((365.25 * (year + 4716))) + trunc((30.6001 * (month + 1))) + day) - 1524.5
969857
public Date makeDateFrom( Object obj )
  {
    if( obj == null )
    {
      return null;
    }

    if( obj instanceof IDimension )
    {
      obj = ((IDimension)obj).toNumber();
    }

    if( obj instanceof Date )
    {
      return (Date)obj;
    }

    if( obj instanceof Number )
    {
      return new Date( ((Number)obj).longValue() );
    }

    if( obj instanceof Calendar)
    {
      return ((Calendar)obj).getTime();
    }

    if( !(obj instanceof String) )
    {
      obj = obj.toString();
    }

    try
    {
      return parseDateTime( (String)obj );
    }
    catch( Exception e )
    {
      //e.printStackTrace();
    }

    return null;
  }
705542
public static Date newDate(final Date original) {
        return original != null ? new Date(original.getTime()) : null;
    }
402935
function(jd) {
			jd = Math.floor(jd) + 0.5;
			var depoch = jd - this.toJD(475, 1, 1);
			var cycle = Math.floor(depoch / 1029983);
			var cyear = mod(depoch, 1029983);
			var ycycle = 2820;
			if (cyear !== 1029982) {
				var aux1 = Math.floor(cyear / 366);
				var aux2 = mod(cyear, 366);
				ycycle = Math.floor(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1;
			}
			var year = ycycle + (2820 * cycle) + 474;
			year = (year <= 0 ? year - 1 : year);
			var yday = jd - this.toJD(year, 1, 1) + 1;
			var month = (yday <= 186 ? Math.ceil(yday / 31) : Math.ceil((yday - 6) / 30));
			var day = jd - this.toJD(year, month, 1) + 1;
			return this.newDate(year, month, day);
		}