Skip to content

Instantly share code, notes, and snippets.

@bastelflp
Created October 21, 2020 10:46
Show Gist options
  • Save bastelflp/dbfa81fdadb4cb10632ca25bca73ff38 to your computer and use it in GitHub Desktop.
Save bastelflp/dbfa81fdadb4cb10632ca25bca73ff38 to your computer and use it in GitHub Desktop.
Generate dates with calender week
# -*- coding: utf-8 -*-
# Generate dates
# tags: py38
from datetime import date, timedelta
import locale
locale.setlocale(locale.LC_ALL, 'de_DE.utf8') # set locale for weekday abbreviation
# define time range
start = date(2020, 10, 1)
end = date(2020, 12, 31)
# print dates with calender week
for counter in range((end - start).days + 1):
date_tmp = start + timedelta(days=counter)
if date_tmp.isocalendar()[2] == 1: # monday
print('CW {}'.format(date_tmp.isocalendar()[1])) # calender week
print('* {}: '.format(date_tmp.strftime('%Y-%m-%d (%a)'))) # day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment