Find the latest legitimate day.
427503
def replace_u_end_day(day, year, month):
    """"""
    day = day.lstrip('-')
    year = int(year)
    month = int(month.lstrip('-'))
    if day == 'uu' or day == '3u':
        # Use the last day of the month for a given year/month.
        return str(calendar.monthrange(year, month)[1])
    if day == '0u' or day == '1u':
        return day.replace('u', '9')
    if day == '2u' or day == 'u9':
        if month != '02' or calendar.isleap(year):
            return '29'
        elif day == '2u':
            # It is Feburary and not a leap year.
            return '28'
        else:
            # It is February, not a leap year, day ends in 9.
            return '19'
    # 'u2' 'u3' 'u4' 'u5' 'u6' 'u7' 'u8'
    if 1 < int(day[1]) < 9:
        return day.replace('u', '2')
    # 'u0' 'u1'
    if day == 'u1':
        if calendar.monthrange(year, month)[1] == 31:
            # See if the month has a 31st.
            return '31'
        else:
            return '21'
    if day == 'u0':
        if calendar.monthrange(year, month)[1] >= 30:
            return '30'
    else:
        return '20'
485173
def created_today(self):
        """"""
        if self.datetime.date() == datetime.today().date():
            return True
        return False
1070750
def check_due(self):
        """"""
        if self.disabled:
            return False
        if self.is_running:
            return False
        if self.delta is None:
            return False
        last_run = self.last_run
        if last_run is None:
            return True
        now = datetime.utcnow()
        if now > last_run + self.delta:
            return True
        return False
26316
def populate_with_fake_data(interval_days = 7)
      if self.enterprise.fakedata?
        today = Time.now.beginning_of_day
        (today - interval_days.days).to(today, 24.hour).each do |ts|
          Octo::FunnelData.new(
            enterprise_id: self.enterprise_id,
            funnel_slug: self.name_slug,
            ts: ts,
            value: fake_data(self.funnel.count)
          ).save!
        end
      end
    end
302768
def yesterday(self):
        
        if self._yesterday is None:
            self._yesterday = YesterdayList(self._version, account_sid=self._solution['account_sid'], )
        return self._yesterday
674107
def business_day?(date)
      date = date.to_date
      return true if extra_working_dates.include?(date)
      return false unless working_days.include?(date.strftime('%a').downcase)
      return false if holidays.include?(date)
      true
    end
1245
def get_today_all(output='pd'):
    

    data = []
    today = str(datetime.date.today())
    codes = QA_fetch_get_stock_list('stock').code.tolist()
    bestip = select_best_ip()['stock']
    for code in codes:
        try:
            l = QA_fetch_get_stock_day(
                code, today, today, '00', ip=bestip)
        except:
            bestip = select_best_ip()['stock']
            l = QA_fetch_get_stock_day(
                code, today, today, '00', ip=bestip)
        if l is not None:
            data.append(l)

    res = pd.concat(data)
    if output in ['pd']:
        return res
    elif output in ['QAD']:
        return QA_DataStruct_Stock_day(res.set_index(['date', 'code'], drop=False))
1302882
def check_date (self):
        
        now = datetime.date.today()
        if now.day == 7 and now.month == 1:
            msg = _("Happy birthday for LinkChecker, I'm %d years old today!")
            self.comment(msg % (now.year - 2000))
133750
public void goToDate(Calendar date) {
        mScroller.forceFinished(true);
        mCurrentScrollDirection = mCurrentFlingDirection = Direction.NONE;

        date.set(Calendar.HOUR_OF_DAY, 0);
        date.set(Calendar.MINUTE, 0);
        date.set(Calendar.SECOND, 0);
        date.set(Calendar.MILLISECOND, 0);

        if(mAreDimensionsInvalid) {
            mScrollToDay = date;
            return;
        }

        mRefreshEvents = true;

        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR_OF_DAY, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);

        long day = 1000L * 60L * 60L * 24L;
        long dateInMillis = date.getTimeInMillis() + date.getTimeZone().getOffset(date.getTimeInMillis());
        long todayInMillis = today.getTimeInMillis() + today.getTimeZone().getOffset(today.getTimeInMillis());
        long dateDifference = (dateInMillis/day) - (todayInMillis/day);
        mCurrentOrigin.x = - dateDifference * (mWidthPerDay + mColumnGap);
        invalidate();
    }
229452
def tomorrow(date=None):
    """"""
    if not date:
        return _date + datetime.timedelta(days=1)
    else:
        current_date = parse(date)
        return current_date + datetime.timedelta(days=1)
560836
def naturaldate(value):
    """"""
    try:
        value = date(value.year, value.month, value.day)
    except AttributeError:
        # Passed value wasn't date-ish
        return value
    except (OverflowError, ValueError):
        # Date arguments out of range
        return value
    delta = abs_timedelta(value - date.today())
    if delta.days >= 365:
        return naturalday(value, '%b %d %Y')
    return naturalday(value)
400515
def gdate(self):
        """"""
        if self._last_updated == "gdate":
            return self._gdate
        return conv.jdn_to_gdate(self._jdn)
214595
def today(self, symbol):
        

        data = self._get(self.url_for(PATH_TODAY, (symbol)))

        # convert all values to floats
        return self._convert_to_floats(data)
985415
def isBirthday(self):
        
        if not self.birthday:
            return False
        birthday = self.birthdate()
        today = date.today()
        return (birthday.month == today.month and
                birthday.day == today.day)
1182379
def get_daily(self, date=None):
        
        if date == None:
            return self.get("/daily.json")
        url = "/daily/{}/{}/{}.json".format(date.year, date.month, date.day)
        return self.get(url)
84494
def prevmonday(num):
    
    today = get_today()
    lastmonday = today - timedelta(days=today.weekday(), weeks=num)
    return lastmonday
27258
def _get_horoscope(self, day='today'):
        
        if not is_valid_day(day):
            raise HoroscopeException("Invalid day. Allowed days: [today|yesterday|tomorrow]" )

        horoscope = ''.join([str(s).strip() for s in self.tree.xpath('//*[@id="%s"]/p/text()' % day)])

        if day is 'yesterday':
            date = self.date_today - timedelta(days=1)
        elif day is 'today':
            date = self.date_today
        elif day is 'tomorrow':
            date = self.date_today + timedelta(days=1)

        return {
            'date': date.strftime("%Y-%m-%d"),
            'sunsign': self.sunsign.capitalize(),
            'horoscope': horoscope + "(c) Kelli Fox, The Astrologer, http://new.theastrologer.com",
            'meta': self._get_horoscope_meta(day),
            'credit': '(c) Kelli Fox, The Astrologer, http://new.theastrologer.com'
        }