Determine the Julian date for the next or previous weekday
326262
def search_weekday(weekday, jd, direction, offset):
    ''''''
    return weekday_before(weekday, jd + (direction * offset))
114380
def calculeToday(self):
        """"""
        self.__logger.debug("Add today")
        last = datetime.datetime.strptime(self.__lastDay, "%Y-%m-%d")
        today = datetime.datetime.now().date()
        self.__validInterval(last, today)
836296
def todate(self):
        
        arr = get_gregorian_date_from_julian_day(self.tojulianday())
        return datetime.date(int(arr[0]), int(arr[1]), int(arr[2]))
636187
def yesterday(date=None):
    """"""
    if not date:
        return _date - datetime.timedelta(days=1)
    else:
        current_date = parse(date)
        return current_date - datetime.timedelta(days=1)
62093
def next_day(self):
        """"""
        return HDate(self.gdate + datetime.timedelta(1), self.diaspora,
                     self.hebrew)
573594
def weekly(date=datetime.date.today()):
    
    return date - datetime.timedelta(days=date.weekday())
318097
def get_next(weekday, including_today=False):
        
        now = datetime.datetime.now()
        if now.weekday() == weekday.value and including_today:
            delta = datetime.timedelta(days=0)
        elif now.weekday() == weekday.value and not including_today:
            delta = datetime.timedelta(days=7)
        else:
            delta = datetime.timedelta(
                (7 + weekday.value - now.weekday()) % 7
            )  # times delta to next instance
        return Day(now + delta).get_just_date()
1311590
def julian_date(year, month=1, day=1, hour=0, minute=0, second=0.0):
    """"""
    return julian_day(year, month, day) - 0.5 + (
        second + minute * 60.0 + hour * 3600.0) / DAY_S
395751
def weekday_tomorrow(self, date_from=None, date_format=None):
		
		# date de demain que sur les jours de semaine
		return self.delta(days=1, date_from=date_from, date_format=date_format, days_range=[1, 2, 3, 4, 5])
1070589
def next_monday_or_tuesday(dt):
    
    dow = dt.weekday()
    if dow == 5 or dow == 6:
        return dt + timedelta(2)
    elif dow == 0:
        return dt + timedelta(1)
    return dt
377723
def pickNthWeekday(year, month, dayofweek, hour, minute, whichweek):
    """"""
    first = datetime.datetime(year=year, month=month, hour=hour, minute=minute,
                              day=1)
    weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7 + 1))
    for n in xrange(whichweek - 1, -1, -1):
        dt = weekdayone + n * WEEKS
        if dt.month == month:
            return dt
105505
def after_third_friday(day=None):
    
    day = day if day is not None else datetime.datetime.now()
    now = day.replace(day=1, hour=16, minute=0, second=0, microsecond=0)
    now += relativedelta.relativedelta(weeks=2, weekday=relativedelta.FR)
    return day > now
634415
def prev_weekday(weekday):
    """"""
    ix = WEEKDAYS.index(weekday)
    if ix == 0:
        return WEEKDAYS[len(WEEKDAYS)-1]
    return WEEKDAYS[ix-1]
1349642
def nexttime(self, lastts):
        '''
        
        '''
        lastdt = datetime.datetime.fromtimestamp(lastts, tz.utc)
        newvals = {}  # all the new fields that will be changed in datetime of lastts

        # Truncate the seconds part
        newdt = lastdt.replace(second=0)

        for unit, newval in self.reqdict.items():
            dtkey = _TimeunitToDatetime[unit]
            if unit is TimeUnit.DAYOFWEEK:
                newdt = newdt.replace(**newvals)
                newvals = {}
                newval = newdt.day + (6 + newval - newdt.weekday()) % 7 + 1
                if newval > calendar.monthrange(newdt.year, newdt.month)[1]:
                    newval -= 7
            elif unit is TimeUnit.MONTH:
                # As we change the month, clamp the day of the month to a valid value
                newdt = newdt.replace(**newvals)
                newvals = {}
                dayval = _dayofmonth(newdt.day, newval, newdt.year)
                newvals['day'] = dayval
            elif unit is TimeUnit.DAYOFMONTH:
                newdt = newdt.replace(**newvals)
                newvals = {}
                newval = _dayofmonth(newval, newdt.month, newdt.year)

            newvals[dtkey] = newval

        newdt = newdt.replace(**newvals)

        # Then move forward if we have to
        if newdt <= lastdt or \
                self.incunit == TimeUnit.DAYOFWEEK and newdt.weekday() != self.incval:
            if self.incunit is None:
                largest_req = min(self.reqdict.keys())
                tmpunit = _NextUnitMap[largest_req]
                if tmpunit is None:  # required a year and we're already there
                    return 0.0
                # Unless we're going to the next day of week, increment by 1 unit of the next larger unit
                tmpincval = self.reqdict.get(TimeUnit.DAYOFWEEK, 1)
            else:
                tmpunit = self.incunit
                tmpincval = self.incval
            newdt = self._inc(tmpunit, tmpincval, self.reqdict, lastdt, newdt)
            assert newdt > lastdt
        return newdt.timestamp()
673797
public Weekday getDayOfWeek() {

        long utcDays = CALSYS.transform(this);
        return Weekday.valueOf(MathUtils.floorModulo(utcDays + 5, 7) + 1);

    }
56387
function daysOfWeek() {
    var result = [];
    for (var weekday = 0; weekday < 7; weekday++) {
        result.push(moment_1.utc().weekday(weekday).format("dd"));
    }
    return result;
}
61478
def locale_first_weekday():
    """"""
    first_weekday = 6 #by default settle on monday

    try:
        process = os.popen("locale first_weekday week-1stday")
        week_offset, week_start = process.read().split('\n')[:2]
        process.close()
        week_start = dt.date(*time.strptime(week_start, "%Y%m%d")[:3])
        week_offset = dt.timedelta(int(week_offset) - 1)
        beginning = week_start + week_offset
        first_weekday = int(beginning.strftime("%w"))
    except:
        logger.warn("WARNING - Failed to get first weekday from locale")

    return first_weekday