Python dateutil.rrule.DAILY Examples
The following are 30
code examples of dateutil.rrule.DAILY().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
dateutil.rrule
, or try the search function
.
Example #1
Source File: test_imports.py From plugin.video.emby with GNU General Public License v3.0 | 7 votes |
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)
Example #2
Source File: recurrence.py From ls.joyous with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #3
Source File: common.py From koku with GNU Affero General Public License v3.0 | 6 votes |
def date_range(start_date, end_date, step=5): """Create a range generator for dates. Given a start date and end date make an generator that returns the next date in the range with the given interval. """ if isinstance(start_date, str): start_date = parser.parse(start_date) if isinstance(end_date, str): end_date = parser.parse(end_date) dates = rrule(freq=DAILY, dtstart=start_date, until=end_date, interval=step) for date in dates: yield date.date() if end_date not in dates: yield end_date.date()
Example #4
Source File: log_download.py From IRCLogParser with GNU General Public License v3.0 | 6 votes |
def ubuntu_url(start_date, end_date): """ Args: start_date (date object): Starting date from which logs need to be fetched end_date (date object) : Last date for which logs need to be fetched Returns: Yields channel name, current_date, and url at which log for returned channel and current_date is present. """ for current_date in rrule(freq=DAILY, dtstart=start_date, until=end_date): url = UBUNTU_ENDPOINT.format(current_date.year,month=current_date.month, day=current_date.day) r = send_request(url) soup = BeautifulSoup(r) links = soup.findAll(href=re.compile(".txt")) for link in links: channel = link.string channel_ = channel[1:] yield channel, current_date, UBUNTU_CHANNEL_ENDPOINT.format(current_date.year, month=current_date.month, day=current_date.day, channel=channel_)
Example #5
Source File: test_imports.py From bazarr with GNU General Public License v3.0 | 6 votes |
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)
Example #6
Source File: misc.py From entsoe-py with MIT License | 6 votes |
def day_blocks(start, end): """ Create pairs of start and end with max a day 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.DAILY 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
Example #7
Source File: test_recurrence.py From django-ical with MIT License | 5 votes |
def test_every_day(self): """Repeat every day.""" vrecurr = vRecur(utils.build_rrule(freq="DAILY")) assert vrecurr["FREQ"] == "DAILY" assert vrecurr.to_ical().decode() == "FREQ=DAILY" assert len(vrecurr.keys()) == 1
Example #8
Source File: course_daily_metrics.py From figures with MIT License | 5 votes |
def generate_cdm_data_for_course(course_id): """ Just getting it working first, then we'll make the values more reasonable like value = sorted([lower_bound, x, upper_bound])[1] """ cdm_data = [] yesterday = {} end_date = prev_day(datetime.datetime.now()) start_date = days_from(end_date, -180) for dt in rrule(DAILY, dtstart=start_date, until=end_date): enrollment_count = yesterday.get('enrollment_count', 0) + randint(0, 10) average_progress = gen_avg_progress(yesterday.get('average_progress', 0)) average_days_to_complete = randint(10, 30) num_learners_completed = gen_num_learners_completed(yesterday) rec = dict( course_id=course_id, date_for=dt.strftime('%Y-%m-%d'), enrollment_count=enrollment_count, active_learners_today=randint(0, enrollment_count / 2), average_progress=average_progress, average_days_to_complete=average_days_to_complete, num_learners_completed=num_learners_completed, ) cdm_data.append(rec) yesterday = rec return cdm_data
Example #9
Source File: test_recurrence.py From django-ical with MIT License | 5 votes |
def test_daily_byhour(self): """Repeat every day at 10, 12 and 17.""" vrecurr = utils.build_rrule(freq="DAILY", byhour=[10, 12, 17]) assert vrecurr["FREQ"] == "DAILY" assert vrecurr["BYHOUR"] == [10, 12, 17] vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY;BYHOUR=10,12,17" assert len(vrecurr.keys()) == 2
Example #10
Source File: test_recurrence.py From django-ical with MIT License | 5 votes |
def test_daily_byhour_once(self): """Repeat every day at 10.""" vrecurr = utils.build_rrule(freq="DAILY", byhour=10) assert vrecurr["FREQ"] == "DAILY" assert vrecurr["BYHOUR"] == 10 vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY;BYHOUR=10" assert len(vrecurr.keys()) == 2
Example #11
Source File: test_recurrence.py From django-ical with MIT License | 5 votes |
def test_every_day(self): """Repeat every day.""" vrecurr = utils.build_rrule_from_text("FREQ=DAILY") assert vrecurr["FREQ"] == ["DAILY"] vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY" assert len(vrecurr.keys()) == 1
Example #12
Source File: test_recurrence.py From django-ical with MIT License | 5 votes |
def test_daily_byhour(self): """Repeat every day at 10, 12 and 17.""" vrecurr = utils.build_rrule_from_text("FREQ=DAILY;BYHOUR=10,12,17") assert vrecurr["FREQ"] == ["DAILY"] assert vrecurr["BYHOUR"] == [10, 12, 17] vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY;BYHOUR=10,12,17" assert len(vrecurr.keys()) == 2
Example #13
Source File: log_download.py From IRCLogParser with GNU General Public License v3.0 | 5 votes |
def scummvm_url(start_date, end_date): """ Args: start_date (date object): Starting date from which logs need to be fetched end_date (date object) : Last date for which logs need to be fetched Returns: Yields channel name, current_date, and url at which log for returned channel and current_date is present. """ for current_date in rrule(freq=DAILY, dtstart=start_date, until=end_date): yield "#scummvm.txt", current_date, SCUMMVM_ENDPOINT.format(day=current_date.day, month=current_date.strftime('%b'), year=current_date.year)
Example #14
Source File: test_log_downloader.py From IRCLogParser with GNU General Public License v3.0 | 5 votes |
def mock_url_endpoint(start_date, end_date): for current_date in rrule(freq=DAILY, dtstart=start_date, until=end_date): yield "kubuntu", current_date, "www.google.com"
Example #15
Source File: lib_words.py From AIL-framework with GNU Affero General Public License v3.0 | 5 votes |
def create_curve_from_redis_set(server, csvfilename, set_to_plot, year, month): """Create a csv file used with dygraph. :param r_serv: -- connexion to redis database :param csvfilename: -- the path to the .csv file created :param to_plot: -- the list which contain a words to plot. :param year: -- (integer) The year to process :param month: -- (integer) The month to process This function create a .csv file using datas in redis. It's checking if the words contained in set_to_plot and their respectives values by days exists. """ first_day = date(year, month, 1) last_day = date(year, month, calendar.monthrange(year, month)[1]) redis_set_name = set_to_plot + "_set_" + str(year) + str(month).zfill(2) words = list(server.smembers(redis_set_name)) #words = [x.decode('utf-8') for x in words] headers = ['Date'] + words with open(csvfilename+'.csv', 'w') as f: writer = csv.writer(f) writer.writerow(headers) # for each days for dt in rrule(DAILY, dtstart=first_day, until=last_day): row = [] curdate = dt.strftime("%Y%m%d") row.append(curdate) # from the 1srt day to the last of the list for word in words: value = server.hget(word, curdate) if value is None: row.append(0) else: # if the word have a value for the day row.append(value) writer.writerow(row)
Example #16
Source File: test_util.py From palladium with Apache License 2.0 | 5 votes |
def test_rrule_from_dict(self, RruleThread): func = Mock() now = datetime.now() rrule_info = { 'freq': 'DAILY', 'dtstart': '2014-10-30T13:21:18', } expected = rrule.rrule( rrule.DAILY, dtstart=datetime(2014, 10, 30, 13, 21, 18)) thread = RruleThread(func, rrule_info) assert thread.rrule.after(now) == expected.after(now)
Example #17
Source File: servustv_com.py From PyFeeds with GNU Affero General Public License v3.0 | 5 votes |
def start_requests(self): today = datetime.now(gettz("Europe/Vienna")).replace(hour=0, minute=0, second=0) for day in rrule.rrule(freq=rrule.DAILY, count=14, dtstart=today): yield Request( "https://www.servustv.com/wp-admin/admin-ajax.php?" + "action=rbmh_tv_program_select_date&date={}".format( day.strftime("%Y-%m-%d") ), # meta={"dont_cache": True}, )
Example #18
Source File: core.py From gips with GNU General Public License v2.0 | 5 votes |
def dates(cls, asset, tile, dates, days): """ For a given asset get all dates possible (in repo or not) - used for fetch """ from dateutil.rrule import rrule, DAILY # default assumes daily regardless of asset or tile datearr = rrule(DAILY, dtstart=dates[0], until=dates[1]) dates = [dt for dt in datearr if days[0] <= int(dt.strftime('%j')) <= days[1]] return dates
Example #19
Source File: speed_comparison.py From py-business-calendar with MIT License | 5 votes |
def init_rruleset(): rr = rruleset() rr.rrule(rrule(DAILY, byweekday=(MO,TU,WE,TH,FR), dtstart=datetime.datetime(2010,1,1))) for h in holidays: rr.exdate(h) return rr
Example #20
Source File: test_business_calendar.py From py-business-calendar with MIT License | 5 votes |
def __init__(self): BaseCalendarTest.__init__(self) self.cal = Calendar() rr = rruleset() rr.rrule(rrule(DAILY, byweekday=(MO,TU,WE,TH,FR), dtstart=datetime.datetime(2010,1,1))) self.rr = rr self.dates = rr.between(datetime.datetime(2010,1,1), datetime.datetime(2013,12,31), inc=True)
Example #21
Source File: test_business_calendar.py From py-business-calendar with MIT License | 5 votes |
def __init__(self): BaseCalendarTest.__init__(self) self.cal = Calendar(workdays=[0,1,4,6]) rr = rruleset() rr.rrule(rrule(DAILY, byweekday=(MO,TU,FR,SU), dtstart=datetime.datetime(2010,1,1))) self.rr = rr self.dates = rr.between(datetime.datetime(2010,1,1), datetime.datetime(2013,12,31), inc=True)
Example #22
Source File: test_business_calendar.py From py-business-calendar with MIT License | 5 votes |
def __init__(self): BaseCalendarTest.__init__(self) self.holidays = [parse(x) for x in global_holidays.split('\n')] self.cal = Calendar(holidays=self.holidays) self.cal.warn_on_holiday_exhaustion = False rr = rruleset() rr.rrule(rrule(DAILY, byweekday=(MO,TU,WE,TH,FR), dtstart=datetime.datetime(2010,1,1))) for h in self.holidays: rr.exdate(h) self.rr = rr self.dates = rr.between(datetime.datetime(2010,1,1), datetime.datetime(2013,12,31), inc=True)
Example #23
Source File: test_business_calendar.py From py-business-calendar with MIT License | 5 votes |
def __init__(self): BaseCalendarTest.__init__(self) self.holidays = [parse(x) for x in global_holidays.split('\n')] self.cal = Calendar(workdays=[0,1,4,6], holidays=self.holidays) rr = rruleset() rr.rrule(rrule(DAILY, byweekday=(MO,TU,FR,SU), dtstart=datetime.datetime(2010,1,1))) for h in self.holidays: rr.exdate(h) self.rr = rr self.dates = rr.between(datetime.datetime(2010,1,1), datetime.datetime(2013,12,31), inc=True)
Example #24
Source File: recurrence.py From ls.joyous with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #25
Source File: util.py From arctic with GNU Lesser General Public License v2.1 | 5 votes |
def get_large_ts(size=2500): timestamps = list(rrule(DAILY, count=size, dtstart=dt(1970, 1, 1), interval=1)) pd = pandas.DataFrame(index=timestamps, data={'n' + str(i): np.random.random_sample(size) for i in range(size)}) pd.index.name = 'index' return pd
Example #26
Source File: calendar.py From Servo with BSD 2-Clause "Simplified" License | 5 votes |
def get_workdays(self, start_date, end_date): WORKDAYS = xrange(0, 5) r = rrule(DAILY, dtstart=start_date, until=end_date, byweekday=WORKDAYS) return r.count()
Example #27
Source File: seed.py From figures with MIT License | 5 votes |
def seed_site_daily_metrics(data=None): """ Run seed_course_daily_metrics first Then, for each date for which we have a CDM record """ end_date = LAST_DAY start_date = days_from(end_date, -DAYS_BACK) for dt in rrule(DAILY, dtstart=start_date, until=end_date): pipeline_sdm.SiteDailyMetricsLoader().load( site=get_site(), date_for=dt, force_update=True)
Example #28
Source File: test_site_daily_metrics_view.py From figures with MIT License | 5 votes |
def generate_sdm_series(site, first_day, last_day): return [SiteDailyMetricsFactory(site=site, date_for=dt) for dt in rrule(DAILY, dtstart=first_day, until=last_day)]
Example #29
Source File: test_metrics.py From figures with MIT License | 5 votes |
def create_student_module_test_data(start_date, end_date): ''' NOTE: There are many combinations of unique students, courses, and student state. We're going to start with a relatively simple set 1. A single course 2. A single set per student (learner) 3. a small number of students to reduce test run time If we create a record per day then we can work off of a unique datapoint per day ''' student_modules = [] user = UserFactory() course_overview = CourseOverviewFactory() for dt in rrule(DAILY, dtstart=start_date, until=end_date): student_modules.append(StudentModuleFactory( student=user, course_id=course_overview.id, created=dt, modified=dt, )) # we'll return everything we create return dict( user=user, course_overview=course_overview, student_modules=student_modules, )
Example #30
Source File: test_metrics.py From figures with MIT License | 5 votes |
def create_site_daily_metrics_data(site, start_date, end_date): ''' NOTE: We can generalize this and the `create_course_daily_metrics_data` function with considering that the course mertrics creation method can assign a course id. When we become site-aware, then the site metrics will also need to be able to assign a site identifier ''' def incr_func(key): return dict( cumulative_active_user_count=2, todays_active_user_count=2, total_user_count=5, course_count=1, total_enrollment_count=3, ).get(key, 0) # Initial values data = dict( cumulative_active_user_count=50, todays_active_user_count=10, total_user_count=5, course_count=5, total_enrollment_count=100, ) metrics = [] for dt in rrule(DAILY, dtstart=start_date, until=end_date): metrics.append(SiteDailyMetricsFactory( date_for=dt, site=site, **data)) data.update( {key: val + incr_func(key) for key, val in data.iteritems()}) return metrics