returns julian day=day since Jan 1 of year
358071
def julianDay(year, month, day):
    ""
    hr = 12  #make sure you fall into right day, middle is save
    t = time.mktime((year, month, day, hr, 0, 0.0, 0, 0, -1))
    julDay = time.localtime(t)[7]
    return julDay
24039
def to_jd(year, month, day):
    ""
    return day + (month - 1) * 30 + (year - 1) * 365 + floor(year / 4) + EPOCH - 1
1229600
def gday_of_year(self):
        """"""
        return (self.date - dt.date(self.date.year, 1, 1)).days
303717
def julian_datetime(julianday, milisecond=0):
    
    if julianday <= 1721423:
        # no datetime before year 1
        return None

    a = julianday + 1
    if a > 2299160:
        alpha = math.trunc((a - 1867216.25) / 36524.25)
        a += 1 + alpha - alpha // 4
    b = a + (1524 if a > 1721423 else 1158)
    c = math.trunc((b - 122.1) / 365.25)
    d = math.trunc(365.25 * c)
    e = math.trunc((b - d) / 30.6001)

    day = b - d - math.trunc(30.6001 * e)
    month = e - (1 if e < 13.5 else 13)
    year = c - (4716 if month > 2.5 else 4715)

    hour, milisecond = divmod(milisecond, 1000 * 60 * 60)
    minute, milisecond = divmod(milisecond, 1000 * 60)
    second, milisecond = divmod(milisecond, 1000)

    return datetime.datetime(year, month, day,
                             hour, minute, second, milisecond)
156824
private static long elapsedDays(int year) {
    int y = year - 1;
    return DAYS_IN_YEAR * (long)y + div(y, 400) - div(y, 100) + div(y, 4);
  }
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
92274
def year(self, value=None):
        
        if value is None:
            return self.day() / 365
        else:
            self.millisecond(self.day(value * 365))
376317
function(jd) {
        var date = gregorianCalendar.fromJD(jd);
        var year = this._g2tYear(date.year());
        return this.newDate(year, date.month(), date.day());
    }
268289
public static function julianToHijri(float $julianDay)
    {
        $y = 10631.0 / 30.0;
        $epochAstro = 1948084;
        $shift1 = 8.01 / 60.0;

        $z = $julianDay - $epochAstro;
        $cyc = floor($z / 10631.0);
        $z = $z - 10631 * $cyc;
        $j = floor(($z - $shift1) / $y);
        $z = $z - floor($j * $y + $shift1);

        $year = 30 * $cyc + $j;
        $month = (int)floor(($z + 28.5001) / 29.5);
        if ($month === 13)
        {
            $month = 12;
        }

        $day = $z - floor(29.5001 * $month - 29);

        return (object) ['year' => (int) $year, 'month' => (int) $month, 'day' => (int) $day];
    }
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
375395
def to_jd(year, month, day):
    ''''''
    gy = year - 1 + EPOCH_GREGORIAN_YEAR

    if month != 20:
        m = 0
    else:
        if isleap(gy + 1):
            m = -14
        else:
            m = -15
    return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day
803142
def ut1(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
            jd=None):
        
        if jd is not None:
            ut1 = jd
        else:
            ut1 = julian_date(
                _to_array(year), _to_array(month), _to_array(day),
                _to_array(hour), _to_array(minute), _to_array(second),
            )
        return self.ut1_jd(ut1)
957373
def _iso_year_start(iso_year):
    ""
    fourth_jan = dt.date(iso_year, 1, 4)
    delta = dt.timedelta(fourth_jan.isoweekday()-1)
    return fourth_jan - delta
1130908
def julian(mon, day, year):
    
    ig = 15 + 31 * (10 + 12 * 1582)
    if year == 0:
        print("Julian no can do")
        return
    if year < 0:
        year = year + 1
    if mon > 2:
        julian_year = year
        julian_month = mon + 1
    else:
        julian_year = year - 1
        julian_month = mon + 13
    j1 = int(365.25 * julian_year)
    j2 = int(30.6001 * julian_month)
    j3 = day + 1720995
    julian_day = j1 + j2 + j3
    if day + 31 * (mon + 12 * year) >= ig:
        jadj = int(0.01 * julian_year)
        julian_day = julian_day + 2 - jadj + int(0.25 * jadj)
    return julian_day
1028118
def jd(date = self)
      y30 = (date.year / 30.0).floor
      day_number = 1948084 + y30 * 10631 + day_of_year(date)

      if date.year % 30 == 0
        day_number
      else
        day_number + DAYS_IN_30_YEARS[date.year - y30 * 30 - 1]
      end
    end
270042
private long newYearInSui(long utcDays) {
        long s1 = this.winterOnOrBefore(utcDays);
        long s2 = this.winterOnOrBefore(s1 + 370);
        long m12 = this.newMoonOnOrAfter(s1 + 1);
        long m13 = this.newMoonOnOrAfter(m12 + 1);
        long nextM11 = this.newMoonBefore(s2 + 1);

        if ((lunations(m12, nextM11) == 12) && (this.hasNoMajorSolarTerm(m12) || this.hasNoMajorSolarTerm(m13))) {
            return this.newMoonOnOrAfter(m13 + 1);
        } else {
            return m13;
        }
    }
1183627
def _earth_orientation(date):
    

    ttt = date.change_scale('TT').julian_century
    # a_a = 0.12
    # a_c = 0.26
    # s_prime = -0.0015 * (a_c ** 2 / 1.2 + a_a ** 2) * ttt
    s_prime = - 0.000047 * ttt

    return date.eop.x / 3600., date.eop.y / 3600., s_prime / 3600