當前位置: 首頁>>代碼示例>>Python>>正文


Python relativedelta.weekday方法代碼示例

本文整理匯總了Python中dateutil.relativedelta.weekday方法的典型用法代碼示例。如果您正苦於以下問題:Python relativedelta.weekday方法的具體用法?Python relativedelta.weekday怎麽用?Python relativedelta.weekday使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dateutil.relativedelta的用法示例。


在下文中一共展示了relativedelta.weekday方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testRRuleAll

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def testRRuleAll(self):
        from dateutil.rrule import rrule
        from dateutil.rrule import rruleset
        from dateutil.rrule import rrulestr
        from dateutil.rrule import YEARLY, MONTHLY, WEEKLY, DAILY
        from dateutil.rrule import HOURLY, MINUTELY, SECONDLY
        from dateutil.rrule import MO, TU, WE, TH, FR, SA, SU

        rr_all = (rrule, rruleset, rrulestr,
                  YEARLY, MONTHLY, WEEKLY, DAILY,
                  HOURLY, MINUTELY, SECONDLY,
                  MO, TU, WE, TH, FR, SA, SU)

        for var in rr_all:
            self.assertIsNot(var, None)

        # In the public interface but not in all
        from dateutil.rrule import weekday
        self.assertIsNot(weekday, None) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:21,代碼來源:test_imports.py

示例2: apply

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def apply(self, other):
        other = datetime(other.year, other.month, other.day)

        n = self.n

        wkday, days_in_month = tslib.monthrange(other.year, other.month)
        lastBDay = days_in_month - max(((wkday + days_in_month - 1)
                                        % 7) - 4, 0)

        if n > 0 and not other.day >= lastBDay:
            n = n - 1
        elif n <= 0 and other.day > lastBDay:
            n = n + 1
        other = as_datetime(other) + relativedelta(months=n, day=31)

        if other.weekday() > 4:
            other = other - BDay()
        return other 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:offsets.py

示例3: __init__

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def __init__(self, n=1, **kwds):
        self.n = n
        self.weekday = kwds['weekday']
        self.week = kwds['week']

        if self.n == 0:
            raise ValueError('N cannot be 0')

        if self.weekday < 0 or self.weekday > 6:
            raise ValueError('Day must be 0<=day<=6, got %d' %
                             self.weekday)
        if self.week < 0 or self.week > 3:
            raise ValueError('Week must be 0<=day<=3, got %d' %
                             self.week)

        self.kwds = kwds 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:offsets.py

示例4: _isdst

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def _isdst(self, dt, fold_naive=True):
        # We can't use mktime here. It is unstable when deciding if
        # the hour near to a change is DST or not.
        #
        # timestamp = time.mktime((dt.year, dt.month, dt.day, dt.hour,
        #                         dt.minute, dt.second, dt.weekday(), 0, -1))
        # return time.localtime(timestamp).tm_isdst
        #
        # The code above yields the following result:
        #
        # >>> import tz, datetime
        # >>> t = tz.tzlocal()
        # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
        # 'BRDT'
        # >>> datetime.datetime(2003,2,16,0,tzinfo=t).tzname()
        # 'BRST'
        # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
        # 'BRST'
        # >>> datetime.datetime(2003,2,15,22,tzinfo=t).tzname()
        # 'BRDT'
        # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
        # 'BRDT'
        #
        # Here is a more stable implementation:
        #
        if not self._hasdst:
            return False

        # Check for ambiguous times:
        dstval = self._naive_is_dst(dt)
        fold = getattr(dt, 'fold', None)

        if self.is_ambiguous(dt):
            if fold is not None:
                return not self._fold(dt)
            else:
                return True

        return dstval 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:41,代碼來源:tz.py

示例5: _delta

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def _delta(self, x, isend=0):
        from dateutil import relativedelta
        kwargs = {}
        if x.month is not None:
            kwargs["month"] = x.month
            if x.weekday is not None:
                kwargs["weekday"] = relativedelta.weekday(x.weekday, x.week)
                if x.week > 0:
                    kwargs["day"] = 1
                else:
                    kwargs["day"] = 31
            elif x.day:
                kwargs["day"] = x.day
        elif x.yday is not None:
            kwargs["yearday"] = x.yday
        elif x.jyday is not None:
            kwargs["nlyearday"] = x.jyday
        if not kwargs:
            # Default is to start on first sunday of april, and end
            # on last sunday of october.
            if not isend:
                kwargs["month"] = 4
                kwargs["day"] = 1
                kwargs["weekday"] = relativedelta.SU(+1)
            else:
                kwargs["month"] = 10
                kwargs["day"] = 31
                kwargs["weekday"] = relativedelta.SU(-1)
        if x.time is not None:
            kwargs["seconds"] = x.time
        else:
            # Default is 2AM.
            kwargs["seconds"] = 7200
        if isend:
            # Convert to standard time, to follow the documented way
            # of working with the extra hour. See the documentation
            # of the tzinfo class.
            delta = self._dst_offset - self._std_offset
            kwargs["seconds"] -= delta.seconds + delta.days * 86400
        return relativedelta.relativedelta(**kwargs) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:42,代碼來源:tz.py

示例6: testRelativeDeltaAll

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def testRelativeDeltaAll(self):
        from dateutil.relativedelta import relativedelta
        from dateutil.relativedelta import MO, TU, WE, TH, FR, SA, SU

        for var in (relativedelta, MO, TU, WE, TH, FR, SA, SU):
            self.assertIsNot(var, None)

        # In the public interface but not in all
        from dateutil.relativedelta import weekday
        self.assertIsNot(weekday, None) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:12,代碼來源:test_imports.py

示例7: onOffset

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def onOffset(cls, dt):
        return dt.weekday() < 5 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:4,代碼來源:offsets.py

示例8: isAnchored

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def isAnchored(self):
        return (self.n == 1 and self.weekday is not None) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:4,代碼來源:offsets.py

示例9: rule_code

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def rule_code(self):
        suffix = ''
        if self.weekday is not None:
            suffix = '-%s' % (_int_to_weekday[self.weekday])
        return self._prefix + suffix 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:7,代碼來源:offsets.py

示例10: _from_name

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def _from_name(cls, suffix=None):
        if not suffix:
            weekday = None
        else:
            weekday = _weekday_to_int[suffix]
        return cls(weekday=weekday) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:offsets.py

示例11: getOffsetOfMonth

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def getOffsetOfMonth(self, dt):
        w = Week(weekday=self.weekday)
        d = datetime(dt.year, dt.month, 1)

        d = w.rollforward(d)

        for i in range(self.week):
            d = w.apply(d)

        return d 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:offsets.py

示例12: _get_year_end_nearest

# 需要導入模塊: from dateutil import relativedelta [as 別名]
# 或者: from dateutil.relativedelta import weekday [as 別名]
def _get_year_end_nearest(self, dt):
        target_date = self.get_target_month_end(dt)
        if target_date.weekday() == self.weekday:
            return target_date
        else:
            forward = target_date + self._rd_forward
            backward = target_date + self._rd_backward

            if forward - target_date < target_date - backward:
                return forward
            else:
                return backward 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:14,代碼來源:offsets.py


注:本文中的dateutil.relativedelta.weekday方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。