3 changed files with 417 additions and 0 deletions
@ -0,0 +1,233 @@ |
|||
#!/usr/bin/python3 |
|||
|
|||
import math |
|||
import json |
|||
|
|||
from datetime import timedelta |
|||
from datetime import date |
|||
import locale |
|||
import os |
|||
|
|||
start_year = 2020 |
|||
start_date = date(start_year, 1, 1) |
|||
end_date = date(start_year, 12, 31) |
|||
|
|||
main_filename = "calender" |
|||
main_tex = main_filename + ".tex" |
|||
main_aux = main_filename + ".aux" |
|||
main_log = main_filename + ".log" |
|||
main_pdf = main_filename + ".pdf" |
|||
|
|||
dates_color = { |
|||
"birthdays": "orange!50!green", |
|||
"specialdays": "red!20!green", |
|||
"freedays": "blue!30!green", |
|||
"holidays": "blue!40!green", |
|||
} |
|||
|
|||
dates = { |
|||
"birthdays": [ |
|||
{ "date": "18.10", "title": "Theresa Voigt" }, |
|||
{ "date": "13.11", "title": "Winfried Voigt"}, |
|||
{ "date": "13.11", "title": "Monika Voigt"}, |
|||
{ "date": "13.11", "title": "Ursula Donn"}, |
|||
{ "date": "14.11", "title": "Philipp Schönberer" }, |
|||
{ "date": "13.01", "title": "Astrid Schönberger" }, |
|||
{ "date": "26.01", "title": "David Geiser" }, |
|||
], |
|||
"birthdays": [ |
|||
{ "date": "05.10", "title": "Obermegaknutztag" }, |
|||
{ "date": "10.05", "title": "Hochzeitstag" }, |
|||
], |
|||
"holidays": [ |
|||
{ "date-start": "23.12.2019", "date-end": "04.01.2020", "title": "Weihnachtsferien" }, |
|||
#Faschingsferien |
|||
{ "date-start": "06.04.2020", "date-end": "18.04.2020", "title": "Osterferien" }, |
|||
{ "date-start": "02.06.2020", "date-end": "13.06.2020", "title": "Pfingstferien"}, |
|||
{ "date-start": "30.07.2020", "date-end": "12.09.2020", "title": "Sommerferien"}, |
|||
{ "date-start": "26.10.2020", "date-end": "30.10.2020", "title": "Herbstferien"}, |
|||
{ "date-start": "23.12.2020", "date-end": "09.01.2021", "title": "Weihnachtsferien"}, |
|||
], |
|||
"freedays": [ |
|||
{ "date": "01.01", "title": "Neujahr" }, |
|||
{ "date": "06.01", "title": "Heilige Drei Könige" }, |
|||
{ "date": "10.04", "title": "Karfreitag" }, |
|||
{ "date": "13.04", "title": "Ostermontag" }, |
|||
{ "date": "01.05", "title": "Tag der Arbeit" }, |
|||
{ "date": "21.05", "title": "Christi Himmelfahrt" }, |
|||
{ "date": "01.06", "title": "Pfingstmontag" }, |
|||
{ "date": "11.06", "title": "Fronleichnam" }, |
|||
{ "date": "03.10", "title": "Tag der Deutschen Einheit"}, |
|||
{ "date": "01.11", "title": "Allerheiligen" }, |
|||
{ "date": "24.12", "title": "Weihnachtten" }, |
|||
{ "date": "25.12", "title": "1. Weihnachtsfeiertag" }, |
|||
{ "date": "26.12", "title": "2. Weihnachtsfeiertag" }, |
|||
{ "date": "31.12", "title": "Silvester" }, |
|||
], |
|||
} |
|||
|
|||
|
|||
|
|||
def get_special_text(date_to_check, divider): |
|||
return_str ="" |
|||
for b in dates: |
|||
print(b) |
|||
for d in dates[b]: |
|||
if "date" in d: |
|||
start_day = d["date"].split(".") |
|||
if len(start_day)<3: |
|||
s_year = date_to_check.year |
|||
else: |
|||
s_year = int(start_day[2]) |
|||
s_month = int(start_day[1]) |
|||
s_day = int(start_day[0]) |
|||
start_day = date(s_year, s_month, s_day) |
|||
if (start_day == date_to_check): |
|||
if return_str != "": |
|||
return_str += divider |
|||
return_str += "\\textcolor{"+dates_color[b]+"}{" + d["title"] + "}" |
|||
|
|||
|
|||
if "date-start" in d and "date-end" in d: |
|||
start_day = d["date-start"].split(".") |
|||
if len(start_day)<3: |
|||
s_year = date_to_check.year |
|||
else: |
|||
s_year = int(start_day[2]) |
|||
s_month = int(start_day[1]) |
|||
s_day = int(start_day[0]) |
|||
start_day = date(s_year, s_month, s_day) |
|||
|
|||
end_day = d["date-end"].split(".") |
|||
if len(end_day)<3: |
|||
e_year = date_to_check.year |
|||
else: |
|||
e_year = int(end_day[2]) |
|||
e_month = int(end_day[1]) |
|||
e_day = int(end_day[0]) |
|||
end_day = date(e_year, e_month, e_day) |
|||
|
|||
if date_to_check >= start_day and date_to_check <= end_day: |
|||
if return_str != "": |
|||
return_str += divider |
|||
return_str += "\\textcolor{"+dates_color[b]+"}{" + d["title"] + "}" |
|||
|
|||
return return_str |
|||
|
|||
def main(): |
|||
# german |
|||
locale.setlocale(locale.LC_TIME, "de_DE") |
|||
|
|||
fd = open(main_tex, "w") |
|||
tex_write_header(fd) |
|||
|
|||
#tex_write_calender_overview(fd) |
|||
|
|||
tex_write_weekly(fd) |
|||
|
|||
tex_write_footer(fd) |
|||
|
|||
fd.close() |
|||
|
|||
cmd = 'pdflatex ' + main_tex |
|||
|
|||
os.system(cmd) |
|||
os.remove(main_aux) |
|||
os.remove(main_log) |
|||
|
|||
|
|||
def tex_write_header(fd): |
|||
start_fd = open("./vorlagen/week_2pages_start.tex", "r") |
|||
for line in start_fd: |
|||
fd.write(line) |
|||
fd.write("\\begin{document}\n"); |
|||
return |
|||
|
|||
|
|||
def tex_write_footer(fd): |
|||
fd.write("\\end{document}\n"); |
|||
return |
|||
|
|||
def tex_write_calender_overview(fd): |
|||
return |
|||
|
|||
|
|||
def tex_write_weekly(fd): |
|||
print_start_date = start_date - timedelta(days=start_date.weekday()) |
|||
print_end_date = end_date + timedelta(days=6 - end_date.weekday()) |
|||
|
|||
print(print_start_date.isoformat()) |
|||
print(print_end_date.isoformat()) |
|||
|
|||
fd.write("%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); |
|||
fd.write("% begin real calender \n"); |
|||
|
|||
curr_date = print_start_date; |
|||
|
|||
print("year : " + str(curr_date.year)) |
|||
|
|||
last_year= "" |
|||
last_month= "" |
|||
|
|||
while True: |
|||
if curr_date.weekday() == 0 or curr_date.weekday() == 3: |
|||
# new year to setup |
|||
if str(curr_date.year) != str(last_year): |
|||
last_year= curr_date.year |
|||
fd.write("\n\\renewcommand{\year}{"+ str(curr_date.year) +"}\n") |
|||
|
|||
# new month to setup |
|||
if str(curr_date.month) != str(last_month): |
|||
last_month= curr_date.month |
|||
fd.write("\n\\renewcommand{\month}{" + curr_date.strftime('%B') + "}\n") |
|||
|
|||
# should give |
|||
# \printweek{KW10}{1}{}{2}{}{3}{} |
|||
|
|||
weeknumber = curr_date.strftime("%V") |
|||
daynumber = curr_date.strftime("%d") |
|||
devider = "\\newline \n" |
|||
special_text = get_special_text(curr_date, devider) |
|||
|
|||
# check for new week |
|||
if curr_date.weekday() == 0: # monday |
|||
fd.write("\\printweek") |
|||
fd.write("{KW" + weeknumber + "}") |
|||
|
|||
if curr_date.weekday() == 3: # thursday is on second page |
|||
fd.write("\n") |
|||
fd.write("\\newpage\n") |
|||
fd.write("\\printweekend") |
|||
fd.write("{KW" + weeknumber + "}") |
|||
|
|||
|
|||
# done for every day |
|||
fd.write("{" + daynumber + "}") |
|||
fd.write("{" + special_text + "}") |
|||
|
|||
if curr_date.weekday() == 6: # sunday is end of week so close it |
|||
fd.write("\n") |
|||
|
|||
# end of calender |
|||
if (print_end_date == curr_date): |
|||
break |
|||
|
|||
#go to next day |
|||
next_date = curr_date + timedelta(days=1) |
|||
|
|||
|
|||
# use the new curr date and contiue |
|||
curr_date = next_date |
|||
|
|||
# end of for each day |
|||
|
|||
fd.write(''' |
|||
% end real calender |
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|||
''') |
|||
return |
|||
|
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
main() |
@ -0,0 +1,8 @@ |
|||
\include{week_2pages_start} |
|||
\begin{document} |
|||
\renewcommand{\year}{2019} |
|||
\renewcommand{\month}{Dezember} |
|||
\printweek{KW10}{1}{}{2}{}{3}{} |
|||
\newpage |
|||
\printweekend{KW10}{4}{Knutzis duzis megapuspsi}{5}{}{6}{}{7}{} |
|||
\end{document} |
@ -0,0 +1,176 @@ |
|||
\documentclass[tikz]{standalone}% Does not support leap years. |
|||
|
|||
%% Load needed packages |
|||
\usepackage{lmodern} |
|||
\usepackage{tikz} |
|||
\usetikzlibrary{positioning} |
|||
\usepackage{ifthen} |
|||
\usepackage{xifthen}% provides \isempty test |
|||
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|||
|
|||
\tikzset{year/.style={minimum height = 2em}} |
|||
\tikzset{dayname/.style={node font=\large}} |
|||
\tikzset{daynumber/.style={node font=\large\bfseries}} |
|||
\tikzset{dayspecialname/.style={node font=\small\bfseries,anchor=west, align=left, text width=5.5cm }} |
|||
\tikzset{dayspecial/.style={color=blue!50!green}} |
|||
\tikzset{month/.style={node font=\large}} |
|||
\tikzset{kw/.style={node font=\large}} |
|||
|
|||
\newcommand{\monday}[0]{Montag} |
|||
\newcommand{\tuesday}[0]{Dienstag} |
|||
\newcommand{\wednesday}[0]{Mittwoch} |
|||
\newcommand{\thursday}[0]{Donnerstag} |
|||
\newcommand{\friday}[0]{Freitag} |
|||
\newcommand{\saturday}[0]{Samstag} |
|||
\newcommand{\sunday}[0]{Sonntag} |
|||
|
|||
|
|||
\newcommand{\daylines}[5]{ |
|||
\foreach \i in {#1, #2, ..., #3}{% |
|||
\draw [black!30!white, thin] (#4,\i) -- (#5,\i); |
|||
} |
|||
|
|||
} |
|||
|
|||
\newcommand{\taskbox}[5]{ |
|||
\foreach \i in {#1, #2, ..., #3}{% |
|||
\draw [black!30!white, thin,dotted] (#4,\i) -- (#5,\i); |
|||
} |
|||
|
|||
\draw [gray, thin,dotted] (#5, #1) -- (#5,#3); |
|||
\foreach \i in {0, 0.3, ..., 1}{% |
|||
|
|||
\draw [black!30!white, thin,dotted] (#4+\i, #1) -- (#4+\i,#3); |
|||
} |
|||
|
|||
} |
|||
|
|||
\newcommand{\printweek}[7]{ |
|||
% KW |
|||
%monday date of month |
|||
%monday special text |
|||
%tuesday date of month |
|||
%tuesday special text |
|||
%Wednesday date of month |
|||
%Wednesday special text |
|||
|
|||
\begin{tikzpicture}[inner sep=3 pt, |
|||
xscale = 3, |
|||
yscale=-1.5,% CAUTION: axis direction reversed! |
|||
] |
|||
|
|||
\node at (0,0) [year] {\year}; %prints year number |
|||
\node at (0.5,0) [month] {\month}; %prints month name |
|||
\node at (1.25,0) [kw] {#1}; %prints month name |
|||
|
|||
|
|||
\ifthenelse{\isempty{#3}} { |
|||
\node at (0, 0.3) [daynumber] {#2}; |
|||
\node at (0.5,0.3) [dayname] {\monday}; |
|||
} { |
|||
\node at (0, 0.3) [dayspecial,daynumber] {#2}; |
|||
\node at (0, 0.7) [dayspecial,dayspecialname] {#3}; |
|||
\node at (0.5,0.3) [dayspecial,dayname] {\monday}; |
|||
} |
|||
\daylines{1}{1.5}{6.5}{0}{1.9} |
|||
|
|||
\ifthenelse{\isempty{#5}} { |
|||
\node at (2, 0.3) [daynumber] {#4}; |
|||
\node at (2.5,0.3) [dayname] {\tuesday}; |
|||
} { |
|||
\node at (2, 0.3) [dayspecial,daynumber] {#4}; |
|||
\node at (2, 0.7) [dayspecial,dayspecialname] {#5}; |
|||
\node at (2.5,0.3) [dayspecial,dayname] {\tuesday}; |
|||
} |
|||
\daylines{1}{1.5}{6.5}{2}{3.9} |
|||
|
|||
\ifthenelse{\isempty{#7}} { |
|||
\node at (4, 0.3) [daynumber] {#6}; |
|||
\node at (4.5,0.3) [dayname] {\wednesday}; |
|||
} { |
|||
\node at (4, 0.3) [dayspecial,daynumber] {#6}; |
|||
\node at (4, 0.7) [dayspecial,dayspecialname] {#7}; |
|||
\node at (4.5,0.3) [dayspecial,dayname] {\wednesday}; |
|||
} |
|||
\daylines{1}{1.5}{6.5}{4}{5.9} |
|||
|
|||
\taskbox{7}{7.4}{15}{0}{5.9} |
|||
|
|||
|
|||
\node at (6, 15.25) [daynumber] {}; |
|||
|
|||
\end{tikzpicture}% |
|||
} |
|||
|
|||
|
|||
\newcommand{\printweekend}[9]{ |
|||
% KW |
|||
%thursday date of month |
|||
%thursday special text |
|||
%Friday date of month |
|||
%Friday special text |
|||
%Saturday date of month |
|||
%Saturday special text |
|||
%Sunday date of month |
|||
%Sunday special text |
|||
% |
|||
|
|||
\begin{tikzpicture}[inner sep=3 pt, |
|||
xscale = 3, |
|||
yscale=-1.5,% CAUTION: axis direction reversed! |
|||
] |
|||
|
|||
\node at (5.0,0) [year] {\year}; %prints year number |
|||
\node at (5.5,0) [month] {\month}; %prints month name |
|||
\node at (4.5,0) [month] {#1}; %prints month name |
|||
|
|||
\ifthenelse{\isempty{#3}} { |
|||
\node at (0, 0.3) [daynumber] {#2}; |
|||
\node at (0.5,0.3) [dayname] {\thursday}; |
|||
} { |
|||
\node at (0, 0.3) [dayspecial,daynumber] {#2}; |
|||
\node at (0, 0.7) [dayspecial,dayspecialname] {#3}; |
|||
\node at (0.5,0.3) [dayspecial,dayname] {\thursday}; |
|||
} |
|||
\daylines{1}{1.5}{6.5}{0}{1.9} |
|||
|
|||
|
|||
\ifthenelse{\isempty{#5}} { |
|||
\node at (2, 0.3) [daynumber] {#4}; |
|||
\node at (2.5,0.3) [dayname] {\friday}; |
|||
} {% |
|||
\node at (2, 0.3) [dayspecial,daynumber] {#4}; |
|||
\node at (2, 0.7) [dayspecial,dayspecialname] {#5}; |
|||
\node at (2.5,0.3) [dayspecial,dayname] {\friday}; |
|||
}% |
|||
\daylines{1}{1.5}{6.5}{2}{3.9} |
|||
|
|||
\ifthenelse{\isempty{#7}} { |
|||
\node at (4, 0.3) [daynumber,color=orange] {#6}; |
|||
\node at (4.5,0.3) [dayname,color=orange] {\saturday}; |
|||
} {% |
|||
\node at (4, 0.3) [dayspecial,daynumber] {#6}; |
|||
\node at (4, 0.7) [dayspecial,dayspecialname] {#7}; |
|||
\node at (4.5,0.3) [dayspecial,dayname] {\saturday}; |
|||
}% |
|||
\daylines{1}{1.5}{6.5}{4}{5.9} |
|||
|
|||
\ifthenelse{\isempty{#9}} { |
|||
\node at (4, 6.8) [daynumber,color=red] {#8}; |
|||
\node at (4.5,6.8) [dayname,color=red] {\sunday}; |
|||
} {% |
|||
\node at (4, 6.8) [dayspecial,daynumber] {#8}; |
|||
\node at (4, 7.2) [dayspecial,dayspecialname] {#9}; |
|||
\node at (4.5,6.8) [dayspecial,dayname] {\sunday}; |
|||
}% |
|||
\daylines{7.5}{8}{15}{4}{5.9} |
|||
|
|||
\taskbox{7}{7.4}{15}{0}{3.9} |
|||
|
|||
|
|||
\node at (6, 15.25) [daynumber] {}; |
|||
\end{tikzpicture}% |
|||
} |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue