当前位置: 首页>>代码示例>>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;未经允许,请勿转载。