本文整理汇总了Python中dateutil.rrule.YEARLY属性的典型用法代码示例。如果您正苦于以下问题:Python rrule.YEARLY属性的具体用法?Python rrule.YEARLY怎么用?Python rrule.YEARLY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类dateutil.rrule
的用法示例。
在下文中一共展示了rrule.YEARLY属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: year_blocks
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def year_blocks(start, end):
"""
Create pairs of start and end with max a year in between, to deal with usage restrictions on the API
Parameters
----------
start : dt.datetime | pd.Timestamp
end : dt.datetime | pd.Timestamp
Returns
-------
((pd.Timestamp, pd.Timestamp))
"""
rule = rrule.YEARLY
res = []
for day in rrule.rrule(rule, dtstart=start, until=end):
res.append(pd.Timestamp(day))
res.append(end)
res = sorted(set(res))
res = pairwise(res)
return res
示例2: _getWhen
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def _getWhen(self, offset, numDays=1):
retval = ""
if self.freq == DAILY:
retval = self.__getDailyWhen()
elif self.freq == WEEKLY:
retval = self.__getWeeklyWhen(offset)
elif self.freq == MONTHLY:
retval = self.__getMonthlyWhen(offset)
elif self.freq == YEARLY:
retval = self.__getYearlyWhen(offset)
if numDays >= 2:
retval += " "+_("for {n} days").format(n=numDays)
if self.until:
until = self.until + dt.timedelta(days=offset)
retval += " "+_("(until {when})").format(when=dateShortFormat(until))
return retval
示例3: test_every_year
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_every_year(self):
"""Repeat every year."""
vrecurr = utils.build_rrule(freq="YEARLY")
assert vrecurr["FREQ"] == "YEARLY"
vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY"
assert len(vrecurr.keys()) == 1
示例4: test_every_day_in_jan
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_every_day_in_jan(self):
"""Repeat every day in January"""
vrecurr = utils.build_rrule(
freq="YEARLY", bymonth=1, byday=["MO", "TU", "WE", "TH", "FR", "SA", "SU"]
)
assert vrecurr["FREQ"] == "YEARLY"
assert vrecurr["BYMONTH"] == 1
assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR", "SA", "SU"]
vRecur(
vrecurr
).to_ical().decode() == "FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYMONTH=1"
assert len(vrecurr.keys()) == 3
示例5: test_every_fr_13th
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_every_fr_13th(self):
"""Repeat every Friday the 13th."""
vrecurr = utils.build_rrule(freq="YEARLY", bymonthday=13, byday="FR")
assert vrecurr["FREQ"] == "YEARLY"
assert vrecurr["BYMONTHDAY"] == 13
assert vrecurr["BYDAY"] == "FR"
vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;BYDAY=FR;BYMONTHDAY=13"
assert len(vrecurr.keys()) == 3
示例6: test_yearly_month_nweekday
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_yearly_month_nweekday(self):
rule = rrule(
YEARLY,
count=3,
bymonth=(1, 3),
byweekday=(TU(1), TH(-1)),
dtstart=datetime.datetime(1997, 9, 2, 9, 0),
)
vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
vRecur(
vrecurr
).to_ical().decode() == "FREQ=YEARLY;COUNT=3;BYDAY=+1TU,-1TH;BYMONTH=1,3"
示例7: test_yearly_month_yearday
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_yearly_month_yearday(self):
rule = rrule(
YEARLY,
count=4,
bymonth=(4, 7),
byyearday=(1, 100, 200, 365),
dtstart=datetime.datetime(1997, 9, 2, 9, 0),
)
vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
assert (
vRecur(vrecurr).to_ical().decode()
== "FREQ=YEARLY;COUNT=4;BYYEARDAY=1,100,200,365;BYMONTH=4,7"
)
示例8: test_yearly_weekno_weekday
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_yearly_weekno_weekday(self):
rule = rrule(
YEARLY,
count=3,
byweekno=1,
byweekday=MO,
dtstart=datetime.datetime(1997, 9, 2, 9, 0),
)
vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;COUNT=3;BYDAY=MO;BYWEEKNO=1"
示例9: test_yearly_setpos
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def test_yearly_setpos(self):
rule = rrule(
YEARLY,
count=3,
bymonthday=15,
byhour=(6, 18),
bysetpos=(3, -3),
dtstart=datetime.datetime(1997, 9, 2, 9, 0),
)
vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
assert (
vRecur(vrecurr).to_ical().decode()
== "FREQ=YEARLY;COUNT=3;BYHOUR=6,18;BYMONTHDAY=15;BYSETPOS=3,-3"
)
示例10: frequency
# 需要导入模块: from dateutil import rrule [as 别名]
# 或者: from dateutil.rrule import YEARLY [as 别名]
def frequency(self):
"""
How often the recurrence repeats.
("YEARLY", "MONTHLY", "WEEKLY", "DAILY")
"""
freqOptions = ("YEARLY", "MONTHLY", "WEEKLY", "DAILY")
if self.rule._freq < len(freqOptions):
return freqOptions[self.rule._freq]
else:
return "unsupported_frequency_{}".format(self.rule._freq)