Based on the year, return the number of days since the epoch.
489386
private long yearToDayOfEpoch(long year)
  {
    if (year > 0) {
      year -= 1601;
      return (365 * year + year / 4 - year / 100 + year / 400 -
              ((1970 - 1601) * 365 + (1970 - 1601) / 4 - 3));
    } else {
      year = 2000 - year;

      return ((2000 - 1970) * 365 + (2000 - 1970) / 4 -
              (365 * year + year / 4 - year / 100 + year / 400));
    }
  }
1008217
def daily_returns(ts, **kwargs):
    '''  '''
    relative = kwargs.get('relative', 0)
    return returns(ts, delta=BDay(), relative=relative)
268505
def date2doy(time: Union[str, datetime.datetime]) -> Tuple[int, int]:
    

    T = np.atleast_1d(time)

    year = np.empty(T.size, dtype=int)
    doy = np.empty_like(year)

    for i, t in enumerate(T):
        yd = str(datetime2yeardoy(t)[0])

        year[i] = int(yd[:4])
        doy[i] = int(yd[4:])

    assert ((0 < doy) & (doy < 366)).all(), 'day of year must be 0 < doy < 366'

    return doy, year
240865
def date_to_epoch(year, month, day):
    
    return int(date_to_delorean(year, month, day).epoch)
475717
def decyear2dt(t):
    
    year = int(t)
    rem = t - year 
    base = datetime(year, 1, 1)
    dt = base + timedelta(seconds=(base.replace(year=base.year+1) - base).total_seconds() * rem)
    #This works for np array input
    #year = t.astype(int)
    #rem = t - year 
    #base = np.array([datetime(y, 1, 1) for y in year])
    return dt
1322351
long calculateFirstDayOfYearMillis(int year) {
        if (year > MAX_YEAR) {
            throw new ArithmeticException("Year is too large: " + year + " > " + MAX_YEAR);
        }
        if (year < MIN_YEAR) {
            throw new ArithmeticException("Year is too small: " + year + " < " + MIN_YEAR);
        }

        // Java epoch is 1970-01-01 Gregorian which is 0622-07-16 Islamic.
        // 0001-01-01 Islamic is -42520809600000L
        // would prefer to calculate against year zero, but leap year
        // can be in that year so it doesn't work
        year--;
        long cycle = year / CYCLE;
        long millis = MILLIS_YEAR_1 + cycle * MILLIS_PER_CYCLE;
        int cycleRemainder = (year % CYCLE) + 1;
        
        for (int i = 1; i < cycleRemainder; i++) {
            millis += (isLeapYear(i) ? MILLIS_PER_LONG_YEAR : MILLIS_PER_SHORT_YEAR);
        }
        
        return millis;
    }
454067
private static int getDayOfCycle(long epochDay, int cycleNumber) {
        Long day;

        try {
            day = ADJUSTED_CYCLES[cycleNumber];
        } catch (ArrayIndexOutOfBoundsException e) {
            day = null;
        }
        if (day == null) {
            day = Long.valueOf(cycleNumber * 10631);
        }
        return (int) (epochDay - day.longValue());
    }
507912
def set_epoch(self, year):
        

        fa.loadapxsh(self.datafile, np.float(year))
        self.year = year
20363
def epiweeks_in_year(year: int) -> int:
    

    if date_to_epiweek(epiweek_to_date(Epiweek(year, 53))).year == year:
        return 53
    else:
        return 52
404846
def data_len_for_day(self, day):
        
        day_ix = self._session_labels.get_loc(day)
        # Add one to the 0-indexed day_ix to get the number of days.
        num_days = day_ix + 1
        return num_days * self._minutes_per_day
909847
private int newYear(int gyear) {

        long cacheValue = newYearCache.get(gyear);

        if (cacheValue == CalendarCache.EMPTY) {

            int solsticeBefore= winterSolstice(gyear - 1);
            int solsticeAfter = winterSolstice(gyear);
            int newMoon1 = newMoonNear(solsticeBefore + 1, true);
            int newMoon2 = newMoonNear(newMoon1 + SYNODIC_GAP, true);
            int newMoon11 = newMoonNear(solsticeAfter + 1, false);
            
            if (synodicMonthsBetween(newMoon1, newMoon11) == 12 &&
                (hasNoMajorSolarTerm(newMoon1) || hasNoMajorSolarTerm(newMoon2))) {
                cacheValue = newMoonNear(newMoon2 + SYNODIC_GAP, true);
            } else {
                cacheValue = newMoon2;
            }

            newYearCache.put(gyear, cacheValue);
        }
        return (int) cacheValue;
    }
364506
def days(self):
        """"""
        monday = self.day(0)
        return [monday + timedelta(days=i) for i in range(7)]
927270
def _get_epoch(_str):
    """"""
    _return = None
    if _str.startswith('A.D. '):
        _return = 'ad'
    elif _str.startswith('a. A.D. '):
        _return = None #?
    elif _str.startswith('p. A.D. '):
        _return = 'ad'
    elif regex.match(r'^[0-9]+ B\.C\. *', _str):
        _return = 'bc'
    elif regex.match(r'^a\. *[0-9]+ B\.C\. *', _str):
        _return = 'bc'
    elif regex.match(r'^p\. *[0-9]+ B\.C\. *', _str):
        _return = None  #?
    elif _str == 'Incertum' or _str == 'Varia':
        _return = _str
    return _return
990844
def _year_from_2digits(short_year, current_year):
        
        if short_year < 100:
            short_year += current_year - (current_year % 100)
            if abs(short_year - current_year) >= 50:
                if short_year < current_year:
                    return short_year + 100
                else:
                    return short_year - 100
        return short_year
991198
public static int getDayOfYear(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(Calendar.DAY_OF_YEAR);
    }
529086
def _start_date_of_year(year: int) -> datetime.date:
    

    jan_one = datetime.date(year, 1, 1)
    diff = 7 * (jan_one.isoweekday() > 3) - jan_one.isoweekday()

    return jan_one + datetime.timedelta(days=diff)
1264924
private static int getCycleNumber(long epochDay) {
        Long[] days = ADJUSTED_CYCLES;
        int cycleNumber;
        try {
            for (int i = 0; i < days.length; i++) {
                if (epochDay < days[i].longValue()) {
                    return i - 1;
                }
            }
            cycleNumber = (int) epochDay / 10631;
        } catch (ArrayIndexOutOfBoundsException e) {
            cycleNumber = (int) epochDay / 10631;
        }
        return cycleNumber;
    }