本文整理汇总了Python中dateutil.relativedelta.FR属性的典型用法代码示例。如果您正苦于以下问题:Python relativedelta.FR属性的具体用法?Python relativedelta.FR怎么用?Python relativedelta.FR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类dateutil.relativedelta
的用法示例。
在下文中一共展示了relativedelta.FR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testRRuleAll
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [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)
示例2: _day_range
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _day_range(self, days):
"""
inspect a given string with days given as integer numbers separated by ","
:param days:
:return: an array with strings containing the days of month
"""
now = datetime.date.today()
wdays = [MO, TU, WE, TH, FR, SA, SU]
result = []
for day in days.split(','):
wday = wdays[int(day)]
# add next weekday occurrence
day = now + dateutil.relativedelta.relativedelta(weekday=wday)
result.append(day.strftime("%d"))
# safety add-on if weekday equals todays weekday
day = now + dateutil.relativedelta.relativedelta(weekday=wday(+2))
result.append(day.strftime("%d"))
return result
示例3: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
e = easter(year)
self[date(year, JAN, 1)] = "Uudenvuodenpäivä"
self[date(year, JAN, 6)] = "Loppiainen"
self[e - rd(days=2)] = "Pitkäperjantai"
self[e] = "Pääsiäispäivä"
self[e + rd(days=1)] = "2. pääsiäispäivä"
self[date(year, MAY, 1)] = "Vappu"
self[e + rd(days=39)] = "Helatorstai"
self[e + rd(days=49)] = "Helluntaipäivä"
self[date(year, JUN, 20) + rd(weekday=SA)] = "Juhannuspäivä"
self[date(year, OCT, 31) + rd(weekday=SA)] = "Pyhäinpäivä"
self[date(year, DEC, 6)] = "Itsenäisyyspäivä"
self[date(year, DEC, 25)] = "Joulupäivä"
self[date(year, DEC, 26)] = "Tapaninpäivä"
# Juhannusaatto (Midsummer Eve) and Jouluaatto (Christmas Eve) are not
# official holidays, but are de facto.
self[date(year, JUN, 19) + rd(weekday=FR)] = "Juhannusaatto"
self[date(year, DEC, 24)] = "Jouluaatto"
示例4: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
# Public holidays
self[date(year, JAN, 1)] = "Nýársdagur"
self[easter(year) - rd(days=3)] = "Skírdagur"
self[easter(year) + rd(weekday=FR(-1))] = "Föstudagurinn langi"
self[easter(year)] = "Páskadagur"
self[easter(year) + rd(days=1)] = "Annar í páskum"
self[date(year, APR, 19) + rd(weekday=TH(+1))] = \
"Sumardagurinn fyrsti"
self[date(year, MAY, 1)] = "Verkalýðsdagurinn"
self[easter(year) + rd(days=39)] = "Uppstigningardagur"
self[easter(year) + rd(days=49)] = "Hvítasunnudagur"
self[easter(year) + rd(days=50)] = "Annar í hvítasunnu"
self[date(year, JUN, 17)] = "Þjóðhátíðardagurinn"
# First Monday of August
self[date(year, AUG, 1) + rd(weekday=MO(+1))] = \
"Frídagur verslunarmanna"
self[date(year, DEC, 24)] = "Aðfangadagur"
self[date(year, DEC, 25)] = "Jóladagur"
self[date(year, DEC, 26)] = "Annar í jólum"
self[date(year, DEC, 31)] = "Gamlársdagur"
示例5: contract_expiry_from_symbol
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def contract_expiry_from_symbol(symbol):
expiry = None
symbol, asset_class = symbol.split("_")
if asset_class == "FUT":
expiry = str(symbol)[-5:]
y = int(expiry[-4:])
m = dataTypes["MONTH_CODES"].index(expiry[:1])
day = datetime(y, m, 1)
expiry = day + relativedelta.relativedelta(weeks=2, weekday=relativedelta.FR)
expiry = expiry.strftime("%Y-%m-%d")
elif asset_class in ("OPT", "FOP"):
expiry = str(symbol)[-17:-9]
expiry = expiry[:4] + "-" + expiry[4:6] + "-" + expiry[6:]
return expiry
# ---------------------------------------------
示例6: testNextFriday
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def testNextFriday(self):
self.assertEqual(self.today+relativedelta(weekday=FR),
date(2003, 9, 19))
示例7: testLastFridayInThisMonth
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def testLastFridayInThisMonth(self):
self.assertEqual(self.today+relativedelta(day=31, weekday=FR(-1)),
date(2003, 9, 26))
示例8: testRelativeDeltaAll
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [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)
示例9: split_by_week
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def split_by_week(competitions: List[Competition]) -> List[Container]:
dt = (dtutil.now(dtutil.WOTC_TZ) + relativedelta(weekday=FR(-1))).replace(hour=0, minute=0, second=0)
weeks = []
while True:
week = Container()
week.start_date = dt
week.end_date = dt + datetime.timedelta(weeks=1)
week.competitions = []
while len(competitions) > 0 and competitions[0].start_date > dt:
week.competitions = week.competitions + [competitions.pop(0)]
weeks.append(week)
dt = dt - datetime.timedelta(weeks=1)
if len(competitions) == 0:
break
return weeks
示例10: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
# Public holidays
self[date(year, JAN, 1)] = "Nytårsdag"
self[easter(year) + rd(weekday=SU(-2))] = "Palmesøndag"
self[easter(year) + rd(weekday=TH(-1))] = "Skærtorsdag"
self[easter(year) + rd(weekday=FR(-1))] = "Langfredag"
self[easter(year)] = "Påskedag"
self[easter(year) + rd(weekday=MO)] = "Anden påskedag"
self[easter(year) + rd(weekday=FR(+4))] = "Store bededag"
self[easter(year) + rd(days=39)] = "Kristi himmelfartsdag"
self[easter(year) + rd(days=49)] = "Pinsedag"
self[easter(year) + rd(days=50)] = "Anden pinsedag"
self[date(year, DEC, 25)] = "Juledag"
self[date(year, DEC, 26)] = "Anden juledag"
示例11: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
# New Years
self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]"
# Maundy Thursday
self[easter(year) + rd(weekday=TH(-1))] =\
"Jueves Santo [Maundy Thursday]"
# Good Friday
self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]"
# Labor Day
self[date(year, MAY, 1)] = "Día del Trabajo [Labour Day]"
# Revolution Day
if 2020 >= year >= 1979:
self[date(year, JUL, 19)] = "Día de la Revolución [Revolution Day]"
# Battle of San Jacinto Day
self[date(year, SEP, 14)] =\
"Batalla de San Jacinto [Battle of San Jacinto]"
# Independence Day
self[date(year, SEP, 15)] =\
"Día de la Independencia [Independence Day]"
# Virgin's Day
self[date(year, DEC, 8)] = "Concepción de María [Virgin's Day]"
# Christmas
self[date(year, DEC, 25)] = "Navidad [Christmas]"
# Provinces festive day
if self.prov:
if self.prov == 'MN':
# Santo Domingo Day Down
self[date(year, AUG, 1)] = "Bajada de Santo Domingo"
# Santo Domingo Day Up
self[date(year, AUG, 10)] = "Subida de Santo Domingo"
示例12: after_third_friday
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def after_third_friday(day=None):
""" check if day is after month's 3rd friday """
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
# =============================================
# timezone utilities
# =============================================
示例13: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
# New Year's Day
self[date(year, JAN, 1)] = "Aña Nobo [New Year's Day]"
# Dia di Betico
self[date(year, JAN, 25)] = "Dia Di Betico [Betico Day]"
# Carnaval Monday
self[easter(year) + rd(days=-48)] = "Dialuna di Carnaval \
[Carnaval Monday]"
# Dia di Himno y Bandera
self[date(year, MAR, 18)] = "Dia di Himno y Bandera \
[National Anthem & Flag Day]"
# Good Friday
self[easter(year) + rd(weekday=FR(-1))] = "Bierna Santo [Good Friday]"
# Easter Monday
self[easter(year) + rd(days=1)] = "Di Dos Dia di Pasco di Resureccion \
[Easter Monday]"
# King's Day
if year >= 2014:
kings_day = date(year, APR, 27)
if kings_day.weekday() == 6:
kings_day = kings_day - rd(days=1)
self[kings_day] = "Aña di Rey [King's Day]"
# Queen's Day
if 1891 <= year <= 2013:
queens_day = date(year, APR, 30)
if year <= 1948:
queens_day = date(year, AUG, 31)
if queens_day.weekday() == 6:
if year < 1980:
queens_day = queens_day + rd(days=1)
else:
queens_day = queens_day - rd(days=1)
self[queens_day] = "Aña di La Reina [Queen's Day]"
# Labour Day
self[date(year, MAY, 1)] = "Dia di Obrero [Labour Day]"
# Ascension Day
self[easter(year) + rd(days=39)] = "Dia di Asuncion [Ascension Day]"
# Christmas Day
self[date(year, DEC, 25)] = "Pasco di Nacemento [Christmas]"
# Second Christmas
self[date(year, DEC, 26)] = "Di Dos Dia di Pasco di \
Nacemento [Second Christmas]"
示例14: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
# New Year's Day
self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]"
# Epiphany
epiphany_day = self.__change_day_by_law(date(year, JAN, 6))
self[epiphany_day] = "Día de los Santos Reyes [Epiphany]"
# Lady of Altagracia
self[date(year, JAN, 21)] = "Día de la Altagracia [Lady of Altagracia]"
# Juan Pablo Duarte Day
duarte_day = self.__change_day_by_law(date(year, JAN, 26))
self[duarte_day] = "Día de Duarte [Juan Pablo Duarte Day]"
# Independence Day
self[date(year, FEB, 27)] = "Día de Independencia [Independence Day]"
# Good Friday
self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]"
# Labor Day
labor_day = self.__change_day_by_law(date(year, MAY, 1), (3, 4, 6))
self[labor_day] = "Día del Trabajo [Labor Day]"
# Feast of Corpus Christi
self[date(year, JUN, 11)] = "Corpus Christi [Feast of Corpus Christi]"
# Restoration Day
# Judgment No. 14 of Feb 20, 2008 of the Supreme Court of Justice
restoration_day = date(year, AUG, 16) if ((year - 2000) % 4 == 0) \
and year < 2008 else self.__change_day_by_law(date(year, AUG, 16))
self[restoration_day] = "Día de la Restauración [Restoration Day]"
# Our Lady of Mercedes Day
self[date(year, SEP, 24)] = "Día de las Mercedes \
[Our Lady of Mercedes Day]"
# Constitution Day
constitution_day = self.__change_day_by_law(date(year, NOV, 6))
self[constitution_day] = "Día de la Constitución [Constitution Day]"
# Christmas Day
self[date(year, DEC, 25)] = "Día de Navidad [Christmas Day]"
示例15: _populate
# 需要导入模块: from dateutil import relativedelta [as 别名]
# 或者: from dateutil.relativedelta import FR [as 别名]
def _populate(self, year):
# New Year's Day
self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]"
# Feast of Saints Peter and Paul
name = "San Pedro y San Pablo [Feast of Saints Peter and Paul]"
self[date(year, JUN, 29)] = name
# Independence Day
name = "Día de la Independencia [Independence Day]"
self[date(year, JUL, 28)] = name
name = "Día de las Fuerzas Armadas y la Policía del Perú"
self[date(year, JUL, 29)] = name
# Santa Rosa de Lima
name = "Día de Santa Rosa de Lima"
self[date(year, AUG, 30)] = name
# Battle of Angamos
name = "Combate Naval de Angamos [Battle of Angamos]"
self[date(year, OCT, 8)] = name
# Holy Thursday
self[easter(year) + rd(weekday=TH(-1))
] = "Jueves Santo [Maundy Thursday]"
# Good Friday
self[easter(year) + rd(weekday=FR(-1))
] = "Viernes Santo [Good Friday]"
# Holy Saturday
self[easter(year) + rd(weekday=SA(-1))
] = "Sábado de Gloria [Holy Saturday]"
# Easter Sunday
self[easter(year) + rd(weekday=SU(-1))
] = "Domingo de Resurrección [Easter Sunday]"
# Labor Day
self[date(year, MAY, 1)] = "Día del Trabajo [Labour Day]"
# All Saints Day
name = "Día de Todos Los Santos [All Saints Day]"
self[date(year, NOV, 1)] = name
# Inmaculada Concepción
name = "Inmaculada Concepción [Immaculate Conception]"
self[date(year, DEC, 8)] = name
# Christmas
self[date(year, DEC, 25)] = "Navidad [Christmas]"