def get_week_agenda(model, queryset, start_date): """ Get list of events that will occur in the given week. :param queryset: EventInstance queryset :param start_date: period start_date :type start_date: datetime.datetime() :return: data dictionary """ period = Week(start_date.year, start_date.date().isocalendar()[1]) end_date = utils.date_to_datetime(period.sunday(), 'max') start_date = utils.date_to_datetime(period.monday()) return { 'start_date': start_date, 'end_date': end_date, 'scope': 'Week', 'items': model.objects.in_date_range(start_date, end_date).filter(event__in=queryset), 'next_date': start_date + timedelta(days=7), 'previous_date': start_date + timedelta(days=-7), }
def convert_to_catergory_str(year, week): isoweek = Week(year, week) monday = isoweek.monday() sunday = isoweek.sunday() return monday.strftime( DATE_FORMAT_SHORT_MONTH_DAY) + '~' + sunday.strftime( DATE_FORMAT_SHORT_MONTH_DAY)
class WeekView(AjaxableViewMixin, CalendarMixin, ListView): model = events.Event context_object_name = 'events' template_name = 'gamenightplanner/calendar/week.html' def dispatch(self, request, year, week, *args, **kwargs): self.week = Week(int(year), int(week)) return super().dispatch(request, *args, **kwargs) def get_queryset(self): return self.model.objects.filter(date__date__gte=self.week.monday(), date__date__lte=self.week.sunday()) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['year'] = self.week.year context['month'] = self.week.monday().month context['week'] = self.week context['daysofweeknames'] = self.DAYSOFWEEK context['daysofweekshort'] = self.DAYSOFWEEK_SHORT context['current_url'] = self.week_link(self.week) context['next_url'] = self.week_link(self.week+1) context['prev_url'] = self.week_link(self.week-1) return context
def execute_goals(self): week_day = datetime.datetime.now().isocalendar()[1] w = Week(datetime.datetime.now().year, week_day) start_date = w.monday() end_date = w.sunday() result = Records.objects.filter( create_date_time__date__range=(start_date, end_date), type_entry__id=1).annotate(total_value=Sum("debit")) try: total_debit = 0 for a in result: total_debit += a.total_value if a.total_value else 0 logging.warning(f"total_debit: {total_debit}") can_use = 770 - total_debit loop = asyncio.get_event_loop() bot = telepot.aio.Bot(settings.TELEGRAM_TOKEN) loop.run_until_complete( bot.sendMessage( self.user_id, f"VocĂȘ ainda pode gastar {can_use} doas 770 reais estipulados para a semana." )) except BaseException as e: logging.exception("Error na meta", e)
def _task_completed(user_id, task_id, year, week_number): """ Return true if a task is completed for this specific user and week """ week = Week(year, week_number) monday = week.monday().isoformat() next_monday = week.sunday() + timedelta(days=1) return _db.is_task_completed(user_id, task_id, monday, next_monday)
def get_week_range(start_date): """ Get the start and end datetimes for the week :param start_date: period start_date :type start_date: datetime.datetime() :return: tuple start_datetime, end_datetime """ period = Week(start_date.year, start_date.date().isocalendar()[1]) start_date = utils.date_to_datetime(period.monday()) end_date = utils.date_to_datetime(period.sunday(), 'max') return start_date, end_date
def get_ini_and_end_date(g: Goal) -> Tuple: if g.period == 1: week_day = datetime.datetime.now().isocalendar()[1] w = Week(datetime.datetime.now().year, week_day) start_date = w.monday() end_date = w.sunday() return start_date, end_date raise Exception("Invalid goal.")
def spent_time_by_day_of_the_week(request, member_id=None, week_of_year=None, board_id=None): user_boards = get_user_boards(request.user) if member_id is None: if user_is_member(request.user): member = request.user.member else: member = Member.objects.filter(boards__in=user_boards)[0] else: member = Member.objects.filter(boards__in=user_boards).distinct().get( id=member_id) if week_of_year is None: now = timezone.now() today = now.date() week_of_year_ = get_iso_week_of_year(today) week_of_year = "{0}W{1}".format(today.year, week_of_year_) y, w = week_of_year.split("W") week = Week(int(y), int(w)) start_of_week = week.monday() end_of_week = week.sunday() chart_title = u"{0}'s spent time in week {1} ({2} - {3})".format( member.external_username, week_of_year, start_of_week.strftime("%Y-%m-%d"), end_of_week.strftime("%Y-%m-%d")) board = None if board_id: board = user_boards.get(id=board_id) chart_title += u" for board {0}".format(board.name) spent_time_chart = pygal.HorizontalBar(title=chart_title, legend_at_bottom=True, print_values=True, print_zeroes=False, human_readable=True) try: day = start_of_week while day <= end_of_week: member_spent_time = member.get_spent_time(day, board) spent_time_chart.add(u"{0}".format(day.strftime("%A")), member_spent_time) day += datetime.timedelta(days=1) except AssertionError: spent_time_chart.no_data_text = u"No developers for this board.\nCheck members' attributes." spent_time_chart.style = DefaultStyle(no_data_font_size=20) return spent_time_chart.render_django_response() return spent_time_chart.render_django_response()
def get_weekly_stats(week, year, store_id, stats_names): result = {} for stats_name in stats_names: weekly_stats = None isoweek = Week(year, week) monday = isoweek.monday() sunday = isoweek.sunday() if stats_name != 'ta_settings': weekly_stats = StoreStats.get_weekly_store_stats( monday.strftime(WEEK_FORMAT), store_id, stats_name) if not weekly_stats: weekly_stats = stats_meta.get(stats_name)(monday, sunday, store_id) # if the week >= this week, do not cache the result because the result will be changed. if week < datetime.datetime.now().isocalendar()[1]: StoreStats.set_weekly_store_stats(monday.strftime(WEEK_FORMAT), store_id, stats_name, weekly_stats) result[stats_name] = weekly_stats return result
def test_days(self): w = Week(2011, 20) self.assertEqual(w.monday().isoformat(), "2011-05-16") self.assertEqual(w.tuesday().isoformat(), "2011-05-17") self.assertEqual(w.wednesday().isoformat(), "2011-05-18") self.assertEqual(w.thursday().isoformat(), "2011-05-19") self.assertEqual(w.friday().isoformat(), "2011-05-20") self.assertEqual(w.saturday().isoformat(), "2011-05-21") self.assertEqual(w.sunday().isoformat(), "2011-05-22") self.assertEqual(w.day(0).isoformat(), "2011-05-16") self.assertEqual(w.day(-1).isoformat(), "2011-05-15") self.assertEqual(w.day(10).isoformat(), "2011-05-26") days = w.days() self.assertEqual(len(days), 7) self.assertEqual(days[0].isoformat(), "2011-05-16") self.assertEqual(days[-1].isoformat(), "2011-05-22") from datetime import date self.assertFalse(w.contains(date(2011, 5, 15))) self.assertTrue(w.contains(date(2011, 5, 16))) self.assertTrue(w.contains(date(2011, 5, 22))) self.assertFalse(w.contains(date(2011, 5, 23)))
def test_days(self): w = Week(2011, 20) self.assertEqual(w.monday().isoformat(), "2011-05-16") self.assertEqual(w.tuesday().isoformat(), "2011-05-17") self.assertEqual(w.wednesday().isoformat(), "2011-05-18") self.assertEqual(w.thursday().isoformat(), "2011-05-19") self.assertEqual(w.friday().isoformat(), "2011-05-20") self.assertEqual(w.saturday().isoformat(), "2011-05-21") self.assertEqual(w.sunday().isoformat(), "2011-05-22") self.assertEqual(w.day(0).isoformat(), "2011-05-16") self.assertEqual(w.day(-1).isoformat(), "2011-05-15") self.assertEqual(w.day(10).isoformat(), "2011-05-26") days = w.days() self.assertEqual(len(days), 7) self.assertEqual(days[0].isoformat(), "2011-05-16") self.assertEqual(days[-1].isoformat(), "2011-05-22") from datetime import date self.assertFalse(w.contains(date(2011,5,15))) self.assertTrue(w.contains(date(2011,5,16))) self.assertTrue(w.contains(date(2011,5,22))) self.assertFalse(w.contains(date(2011,5,23)))
def end_of_week_of_year(week, year): week = Week(year, week) return week.sunday()
if infoboks.has_param(commonargs['week2']): endweek = re.sub( ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['week2']])).strip() if endweek == '': endweek = startweek else: endweek = startweek endweek = int(endweek) startweek = Week(year, startweek) endweek = Week(year, endweek) start = wiki_tz.localize( datetime.combine(startweek.monday(), dt_time(0, 0, 0))) end = wiki_tz.localize( datetime.combine(endweek.sunday(), dt_time(23, 59, 59))) elif infoboks.has_param(ibcfg['start']) and infoboks.has_param(ibcfg['end']): startdt = infoboks.parameters[ibcfg['start']].value enddt = infoboks.parameters[ibcfg['end']].value start = wiki_tz.localize( datetime.strptime(startdt + ' 00 00 00', '%Y-%m-%d %H %M %S')) end = wiki_tz.localize( datetime.strptime(enddt + ' 23 59 59', '%Y-%m-%d %H %M %S')) else: log('!! fant ikke datoer') sys.exit(0) year = start.isocalendar()[0] startweek = start.isocalendar()[1] endweek = end.isocalendar()[1]
def spent_time_by_week(current_user, week_of_year=None, board=None): if week_of_year is None: now = timezone.now() today = now.date() week_of_year_ = get_iso_week_of_year(today) week_of_year = "{0}W{1}".format(today.year, week_of_year_) # Caching chart_uuid = "members.spent_time_by_week-{0}-{1}".format( current_user.id, week_of_year, board.id if board else "user-{0}".format(current_user.id)) chart = CachedChart.get(board=board, uuid=chart_uuid) if chart: return chart y, w = week_of_year.split("W") week = Week(int(y), int(w)) start_of_week = week.monday() end_of_week = week.sunday() chart_title = u"Spent time in week {0} ({1} - {2})".format( week_of_year, start_of_week.strftime("%Y-%m-%d"), end_of_week.strftime("%Y-%m-%d")) if board: chart_title += u" for board {0}".format(board.name) spent_time_chart = pygal.HorizontalBar(title=chart_title, legend_at_bottom=True, print_values=True, print_zeroes=False, human_readable=True) report_filter = {"date__year": y, "week_of_year": w} if board: report_filter["board_id"] = board.id team_spent_time = 0 if board is None: boards = get_user_boards(current_user) else: boards = [board] members = Member.objects.filter( boards__in=boards, is_developer=True).distinct().order_by("id") for member in members: member_name = member.external_username daily_spent_times = member.daily_spent_times.filter(**report_filter) spent_time = daily_spent_times.aggregate( Sum("spent_time"))["spent_time__sum"] if spent_time is None: spent_time = 0 team_spent_time += spent_time if spent_time > 0: spent_time_chart.add(u"{0}'s spent time".format(member_name), spent_time) spent_time_chart.add(u"Team spent time", team_spent_time) chart = CachedChart.make(board=board, uuid=chart_uuid, svg=spent_time_chart.render(is_unicode=True)) return chart.render_django_response()
def for_week(self, year, week_no): from isoweek import Week week = Week(year, week_no) return TimeEntry.objects.filter(date__gte=week.monday(), date__lte=week.sunday())
def admin_schedule(request, room_id): assert is_room_admin(request.user, room_id), 'Member routed to member view.' room = get_object_or_404(Room, pk=room_id) members = RoomMembers.objects.filter(room=room_id) # get all weeks that have cleaning schedule takenWeeks = Tasks.objects.filter(room=room_id).filter(type="clean").filter(task="weekly cleaning") #get all weeks of the year weeks = [] i = 1 while i <= 52: w = Week(2021, i) week = {'week': w.isoformat(), 'weekStart': w.monday().isoformat(), 'weekEnd': w.sunday().isoformat(), 'deadline': None, 'user': None } weeks.append(week) i += 1 context={ 'user': request.user, 'room': room, 'members': members, 'weeks': weeks, 'takenWeeks': takenWeeks } taken = False # assign a week to a room member for cleaning if request.method == 'POST' and 'addBtn' in request.POST: try: dueToWeek = Week.fromstring(request.POST['week']) if takenWeeks: for takenWeek in takenWeeks: if dueToWeek.isoformat() == takenWeek.deadline: context['error'] = "Week is taken" taken = True if taken == False: #create a task for the week of cleaning assignedUser = request.POST['members_choice'] user = get_object_or_404(User, username=assignedUser) Tasks.create(user, room, "weekly cleaning", "clean", dueToWeek) #create a list of subtasks queryset = Tasks.objects.filter(room=room_id) task = get_object_or_404(queryset, deadline=dueToWeek.isoformat()) list = get_object_or_404(List, pk=1) listTasks = ListTasks.objects.filter(list=list) for listTask in listTasks: Subtasks.create(task, listTask.task) return HttpResponseRedirect(reverse('kitchen_app:admin_schedule', args=(room.id,))) except IntegrityError as e: context['error'] = "Week is taken" # remove an assigned week if request.method == 'POST' and 'removeBtn' in request.POST: takenWeekID = request.POST['takenWeekID'] task = get_object_or_404(Tasks, pk=takenWeekID) task.delete() return HttpResponseRedirect(reverse('kitchen_app:admin_schedule', args=(room.id,))) return render(request, 'kitchen_app/admin_cleaning_schedule.html', context)
def cleaning_schedule(request, room_id): room = get_object_or_404(Room, pk=room_id) members = RoomMembers.objects.filter(room=room_id) takenWeeks = Tasks.objects.filter(room=room_id).filter(type="clean").filter(task="weekly cleaning") #get all weeks of the year (year hardcoded) weeks = [] i = 1 while i <= 52: w = Week(2021, i) week = {'week': w.isoformat(), 'weekStart': w.monday().isoformat(), 'weekEnd': w.sunday().isoformat(), 'deadline': None, 'user': None } weeks.append(week) i += 1 context={ 'user': request.user, 'room': room, 'members': members, 'weeks': weeks, 'takenWeeks': takenWeeks } return render(request, 'kitchen_app/cleaning_schedule.html', context)
def get_last_sunday(date): last_week = date + relativedelta(weeks=-1) date_cal = last_week.isocalendar() isoweek = Week(date_cal[0], date_cal[1]) return isoweek.sunday()
def __init__(self, parent, controller): Frame.__init__(self, parent, bg="#f8f8f8") menu_frame = Frame(self, bg="#e7e7e7") menu_frame.pack(fill='both') load = Image.open("home.jpg") render = ImageTk.PhotoImage(load) from landingpage import LandingPage img = Button(menu_frame, image=render, borderwidth=0, highlightthickness=0, highlightbackground="#e7e7e7", command=lambda: controller.show_frame(LandingPage)) img.image = render img.grid(row=0, column=0, sticky="nsew") label = Label(menu_frame, text="Meal Planner", font=LARGE_FONT, bg="#e7e7e7", fg="#272822") label.grid(row=0, column=1, sticky="nsew") grocery_button = Button(menu_frame, text="Grocery List", highlightbackground="#e7e7e7", command=lambda: view_grocery_list()) grocery_button.grid(row=0, column=2, sticky="nsew") view_recipe_frame = Frame(self, bg="#f8f8f8") now = datetime.datetime.now() dt = datetime.date(now.year, now.month, now.day) week_number = dt.isocalendar()[1] w = Week(now.year, week_number) menu = Frame(self, bg="#f8f8f8") menu.pack() column_labels = ["Breakfast", "Lunch", "Dinner"] for i in range(len(column_labels)): Label(menu, text=column_labels[i], font=("Trebuchet MS", 16), bg="#f8f8f8").grid(row=0, column=i+2, pady= 10, padx=85, sticky="nsew") monday_text = "Monday " + str(w.monday()) tuesday_text = "Tuesday " + str(w.tuesday()) wednesday_text = "Wednesday " + str(w.wednesday()) thursday_text = "Thursday " + str(w.thursday()) friday_text = "Friday " + str(w.friday()) saturday_text = "Saturday " + str(w.saturday()) sunday_text = "Sunday " + str(w.sunday()) labels = [monday_text, tuesday_text, wednesday_text, thursday_text, friday_text, saturday_text, sunday_text] for i in range(len(labels)): Label(menu, font=("Trebuchet MS", 12), bg="#f8f8f8", text=labels[i]).grid(row=i+1, column=0, padx = 5, pady=15, sticky="w") sep = ttk.Separator(menu, orient="vertical") sep.grid(row=i+1, column=1, padx=5, sticky="nsew") database_file = "meal_planner.db" tableName = "recipes_" + str(week_number) menuDict = {} with sqlite3.connect(database_file) as conn: cursor = conn.cursor() selection = cursor.execute("""SELECT * FROM """ + tableName) for result in [selection]: for row in result.fetchall(): name = row[0] row_db = row[1] column_db = row[2] menuDict[name] = (row_db, column_db) valueArray = [] keyArray = [] for (key, value) in menuDict.items(): print(key, value) keyArray.append(key) valueArray.append(value) button_dict = {} list_of_buttons = [] for rows in range(len(labels)): for columns in range(len(column_labels)): buttons = Button(menu, text="Add meal", highlightbackground="#f8f8f8", command=lambda x=rows + 1, y=columns + 2: add_meal(x, y)) buttons.grid(row=rows + 1, column=columns + 2) locationTuple = (rows+1, columns+2) for key, value in menuDict.items(): if locationTuple == value: #dont add a button recipeLabel = Label(menu, text=key, bg="#f8f8f8", padx=1, pady=1) recipeLabel.grid(row=value[0], column=value[1]) recipeLabel.bind("<Button-1>", lambda event, x=key: print_recipe(x)) else: buttons.grid(row=rows + 1, column=columns + 2) buttons.position = (rows + 1, columns + 2) button_dict[buttons] = buttons.position list_of_buttons.append(buttons) def add_meal(rowLocation, columnLocation): """Grabs meals from the database to be displayed. Keyword arguments: rowLocation - Row on the grid columnLocation - Column on the grid :return: Nothing """ menu.pack_forget() view_recipe_frame.forget() add_meal_frame = Frame(self, bg="#f8f8f8") add_meal_frame.pack() recipe_names = [] ingredient_list = [] database_file = "meal_planner.db" with sqlite3.connect(database_file) as conn: cursor = conn.cursor() selection = cursor.execute("""SELECT * FROM recipe""") for result in [selection]: for row in result.fetchall(): name = row[0] ingredients = row[4] recipe_names.append(name) ingredient_list.append(ingredients) for i in range(len(recipe_names)): Button(add_meal_frame, text=recipe_names[i], highlightbackground="#f8f8f8", command=lambda x=recipe_names[i], y=ingredient_list[i]:add_recipe(x, y, add_meal_frame, rowLocation, columnLocation)).grid(row=i, column=0) def add_recipe(recipe, ingredients, view, row, column): """Adds recipe name to the grid for the meal plan. Keyword arguments: recipe - recipe name ingredients - ingredients for that recipe view - the add meal frame rowLocation - Row on the grid columnLocation - Column on the grid :return: Nothing """ view.pack_forget() view_recipe_frame.forget() searchIndex = (row, column) for key, value in button_dict.items(): if value == searchIndex: key.destroy() save_weeks_recipes(recipe, row, column) save_ingredients(ingredients) recipe_label = Label(menu, text=recipe, bg="#f8f8f8") recipe_label.grid(row = row, column = column) recipe_label.bind("<Button-1>", lambda event: print_recipe(recipe)) menu.pack() def print_recipe(recipeName): """Prints the recipe info on a new screen. Keyword arguments: recipe - recipe name :return: Nothing """ menu.pack_forget() view_recipe_frame.pack(expand=True, fill='both') grocery_button.grid_forget() database_file = "meal_planner.db" with sqlite3.connect(database_file) as conn: cursor = conn.cursor() selection = cursor.execute("""SELECT * FROM recipe WHERE name = ?;""", (recipeName, )) for result in [selection]: for row in result.fetchall(): name = row[0] time = row[1] servings = row[2] ingredients = row[4] directions = row[5] string = ("Name: {} \n Cook time: {} \n Number of Servings: {} \n ".format(name, time, servings)) second_string = ("Ingredients: {}".format(ingredients)) third_string = ("Directions: {}".format(directions)) Label(view_recipe_frame, text=string, font=MEDIUM_FONT, bg="#f8f8f8", fg="#000000").grid(row=1, column=0, sticky="nsew", padx=400) Label(view_recipe_frame, text=second_string, font=MEDIUM_FONT, bg="#f8f8f8", fg="#000000").grid(row=2, column=0, sticky="nsew") Label(view_recipe_frame, text=third_string, font=MEDIUM_FONT, bg="#f8f8f8", fg="#000000").grid(row=3, column=0, sticky="nsew") return_button = Button(menu_frame, text = "Return to Menu", highlightbackground="#e7e7e7", command=lambda: [view_recipe_frame.pack_forget(), return_button.grid_forget(), menu.pack(), label.configure(text="Meal Planer"), grocery_button.grid(row=0, column=2, sticky="nsew")]) # returnButton.pack(side=RIGHT) return_button.grid(row=0, column=4, sticky="nsew") def view_grocery_list(): """Prints the grocery list for the week. Keyword arguments: None :return: Nothing """ grocery_list_frame = Frame(self, bg="#f8f8f8") grocery_list_frame.pack() menu.pack_forget() grocery_button.grid_forget() label.configure(text="Grocery List") i = 0 database_file = "meal_planner.db" item_array = [] with sqlite3.connect(database_file) as conn: cursor = conn.cursor() tableName = "ingredients_" + str(week_number) selection = cursor.execute("""SELECT * FROM """ + tableName) for result in [selection]: for row in result.fetchall(): print(row) for ingredient in row: print(ingredient) item_array.append(str(ingredient).split()) i = i +1 Label(grocery_list_frame, text=ingredient, bg="#f8f8f8", font=MEDIUM_FONT, justify=LEFT).grid(row=i, column=0, sticky="w") return_button = Button(menu_frame, text = "Return to Menu", highlightbackground="#e7e7e7", command=lambda: [grocery_list_frame.pack_forget(), return_button.grid_forget(), menu.pack(), label.configure(text="Meal Planer"), grocery_button.grid(row=0, column=2, sticky="nsew")]) # returnButton.pack(side=RIGHT) return_button.grid(row=0, column=4, sticky="nsew") def save_ingredients(ingredients): """Save the ingredients to the database so we can get them later for the grocery list. Keyword arguments: ingredients - ingredients to be saved to db :return: Nothing """ database_file = "meal_planner.db" with sqlite3.connect(database_file) as conn: # create the table if it hasn't been created yet tableName = "ingredients_" + str(week_number) conn.execute('''CREATE TABLE IF NOT EXISTS ''' + tableName + ''' (ingredients text)''') conn.execute("""INSERT INTO """ + tableName + """ VALUES (?);""", (ingredients,)) def save_weeks_recipes(recipeName, row, column): """Save the week's recipe so we can keep them between app sessions. Keyword arguments: recipeName - the name of the recipe row - the row the recipe belongs to in the menu grid column - the column the recipe belongs to in the menu grid :return: Nothing """ print("save weeks") database_file = "meal_planner.db" with sqlite3.connect(database_file) as conn: # create the table if it hasn't been created yet tableName = "recipes_" + str(week_number) conn.execute('''CREATE TABLE IF NOT EXISTS ''' + tableName + ''' (recipe text, row int, column int)''') conn.execute("""INSERT INTO """ + tableName + """ VALUES (?, ?, ?);""", (recipeName, row, column))
if infoboks.has_param(commonargs['year']) and infoboks.has_param(commonargs['week']): year = int(re.sub(ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['year']])).strip()) startweek = int(re.sub(ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['week']])).strip()) if infoboks.has_param(commonargs['week2']): endweek = re.sub(ur'<\!--.+?-->', ur'', unicode(infoboks.parameters[commonargs['week2']])).strip() if endweek == '': endweek = startweek else: endweek = startweek endweek = int(endweek) startweek = Week(year, startweek) endweek = Week(year, endweek) start = wiki_tz.localize(datetime.combine(startweek.monday(), dt_time(0, 0, 0))) end = wiki_tz.localize(datetime.combine(endweek.sunday(), dt_time(23, 59, 59))) elif infoboks.has_param(ibcfg['start']) and infoboks.has_param(ibcfg['end']): startdt = infoboks.parameters[ibcfg['start']].value enddt = infoboks.parameters[ibcfg['end']].value start = wiki_tz.localize(datetime.strptime(startdt + ' 00 00 00', '%Y-%m-%d %H %M %S')) end = wiki_tz.localize(datetime.strptime(enddt + ' 23 59 59', '%Y-%m-%d %H %M %S')) else: log('!! fant ikke datoer') sys.exit(0) year = start.isocalendar()[0] startweek = start.isocalendar()[1] endweek = end.isocalendar()[1] figname = config['plot']['figname'] % {'year': year, 'week': startweek}
def weekly_str(value, year): isoweek = Week(year, value) monday = isoweek.monday() sunday = isoweek.sunday() return monday.strftime(DATE_FORMAT) + ' - ' + sunday.strftime(DATE_FORMAT)