-
Notifications
You must be signed in to change notification settings - Fork 0
/
yearly todo.tex
166 lines (155 loc) · 7.15 KB
/
yearly todo.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
%!TEX program = xelatex
% There is an issue with Gregorian leap year via AdvanceDate
%%% Tue 25 May 2021 05:22:50 AM +0430
\documentclass{article}
\usepackage[margin=0pt,a5paper]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{datenumber}
\usepackage{advdate}
\usepackage{xepersian}
\settextfont{XB Shafigh}
% \ExplSyntaxOn \cs_set_eq:NN \etex_iffontchar:D \tex_iffontchar:D \ExplSyntaxOff
\setdigitfont{Yas}
\setlatintextfont{Linux Libertine}
\ExplSyntaxOn
\prg_new_conditional:Npnn \is_leapyear:n #1 { p, T, F, TF }
{
\int_compare:nNnTF { \int_mod:nn {#1} { 4 } } = { 0 }
{
\int_compare:nNnTF { \int_mod:nn {#1} { 100 } } = { 0 }
{
\int_compare:nNnTF { \int_mod:nn {#1} { 400 } } = { 0 }
{ \prg_return_true: }
{ \prg_return_false: }
}
{ \prg_return_true: }
}
{ \prg_return_false: }
}
\newcommand{\isLeapYear}[1]
{
\bool_if:nTF { \is_leapyear_p:n {#1} } {\iftrue} {\iffalse}
}
\ExplSyntaxOff
\makeatletter
\renewcommand\AdvanceDate[1][\@ne]{\global\advance\day#1 \FixDate}
\makeatother
\newif\ifoddpage
\usetikzlibrary{calc}
\def\dom#1{\ifcase#1 Sat\or Sun\or Mon\or Tue\or Wed\or Thu\or Fri\or Sat\fi}
\newcount\monthname
\def\mn{\ifcase\monthname \or فروردین\or اردیبهشت\or خرداد\or تیر\or مرداد\or شهریور\or مهر\or آبان\or آذر\or دی\or بهمن\or اسفند\fi}
\def\mnp{\ifcase\monthname \or March--April\or April--May\or May--June\or June--July\or July--August\or August--September\or September--October\or October--November\or November--December\or December--January\or January--Feburary\or Feburary--March\fi}
\def\emn{\ifcase\count3 \or Jan\or Feb\or Mar\or Apr\or May\or Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\else Jan\fi}
\makeatletter
\newif\ifPersianLeap \PersianLeapfalse
\newcommand\isPersianLeapYear[1]{%
\in@{#1}{1214,1218,1222,1226,1230,1234,1238,1243,1247,1251,1255,1259,1263,1267,1271,%
1276,1276,1280,1284,1288,1292,1296,1300,1305,1309,1313,1317,1321,1325,1329,%
1333,1337,1342,1342,1346,1350,1354,1358,1362,1366,1370,1375,1375,1379,1383,%
1387,1391,1395,1399,1403,1408,1412,1416,1420,1424,1428,1432,1436,1441,1445,%
1449,1453,1457,1461,1465,1469,1474,1478,1482,1486,1490,1494,1498}%
\ifin@\PersianLeaptrue\else\PersianLeapfalse\fi
}
\makeatother
%% Courtesy to https://tex.stackexchange.com/questions/34424/how-do-i-calculate-n-modulo-3-in-latex
\newcount\tmpcnta
\def\modulo#1{\tmpcnta=#1
\divide\tmpcnta by 7
\multiply\tmpcnta by 7
\multiply\tmpcnta by -1
\advance\tmpcnta by #1\relax
#1=\tmpcnta}
%0= Sat, 1=Sun, 2=Mon 3=Tue, 4=Wed, 5=Thu 6=Fri
\newcount\nody %Name of first day of year
\newif\ifsixteen
\makeatletter
\def\yearlytodo#1{% index the starting day of a month
\def\thisyear{#1}%
\isPersianLeapYear{#1}%
\monthname=1%
\sixteentrue%
\oddpagetrue%
\ThisYear{\numexpr #1+621\relax}
\ThisMonth{3}
\ThisDay{\isLeapYear{\the\year}19\else20\fi}
\setdate{\the\year}{\the\month}{\numexpr\day+1\relax} % to set the correct number for datedayname counter.
\nody=\ifcase\thedatedayname\or2\or3\or4\or5\or6\or0\or1\fi
\count2=\isLeapYear{\numexpr\year-1\relax}81\else80\fi % the first day of Jalali calendar is the 80th/81st of the Gregory calendar
\def\edy{\the\count2\global\advance\count2 by 1\relax%
\isLeapYear{\the\year}\ifnum\count2>366\global\count2=1\fi\else\ifnum\count2>365\global\count2=1\fi\fi}
% \expandafter\getdateitems#3
\foreach \dayofyear in {1, 32, 63, 94, 125, 156, 187, 217, 247, 277, 307, 337} {
\foreach \x in {1,2}{%
\ifoddpage%
\global\count0=1%
\ifnum\dayofyear<186 %\global\advance\nody by 1\AdvanceDate\relax
\sixteentrue
\else
\sixteenfalse
\fi%
\else%
\global\count0=\ifnum\dayofyear>186 16\else 17\fi % the starting day in the odd page
\sixteenfalse
\fi%
\ifsixteen % for the first six months of the Persian Calendar
\def\xrange{7.2,7.6,8,8.4,8.8,9.2,9.6,10,10.4,10.8,11.2,11.6,12,12.4,12.8,13.2,13.6,14,14.4,14.8}
\def\xrangeR{14.6,14.2,13.8,13.4,13,12.6,12.2,11.8,11.4,11,10.6,10.2,9.8,9.4,9,8.6} %
\def\ntep{8.2/next week, 7.8/task|event, 7.4/purchase}
\def\tshift{-0.4}
\def\mydraw{\draw (8.4, 18.5) -- (14.8, 18.5);}
\else
\def\xrange{7.6,8,8.4,8.8,9.2,9.6,10,10.4,10.8,11.2,11.6,12,12.4,12.8,13.2,13.6,14,14.4,14.8}
\def\xrangeR{14.6,14.2,13.8,13.4,13,12.6,12.2,11.8,11.4,11,10.6,10.2,9.8,9.4,9} %
\def\ntep{8.6/next week, 8.2/task|event, 7.8/purchase}
\def\tshift{0}
\def\mydraw{\draw (8.8, 18.5) -- (14.8, 18.5);}
\fi
\ifnum\dayofyear>336 \ifnum\x=2
\ifPersianLeap
\else
\def\xrange{8,8.4,8.8,9.2,9.6,10,10.4,10.8,11.2,11.6,12,12.4,12.8,13.2,13.6,14,14.4,14.8}
\def\xrangeR{14.6,14.2,13.8,13.4,13,12.6,12.2,11.8,11.4,11,10.6,10.2,9.8,9.4} %
\def\ntep{9/next week, 8.6/task|event, 8.2/purchase}
\def\tshift{0.4}
\def\mydraw{\draw (9.2, 18.5) -- (14.8, 18.5);}
\fi\fi\fi
\count1=\dayofyear%
\global\advance\count1 by \count0\relax\global\advance\count1 by -1\relax%
\def\sc{\the\count0\global\advance\count0 by 1\relax}
\def\dy{\the\count1\global\advance\count1 by 1\relax} % number of the day in the whole year
\def\dm{\ifnum\nody>7\modulo{\nody}\fi\dom{\nody}\global\advance\nody by 1\relax}
\begin{tikzpicture}%[xshift=-1cm, scale=1.3]
\foreach \y in {0,.7,...,18.7,20.98}
{\draw (0, \y) -- (14.8, \y);}
\mydraw%\draw (8.8, 18.5) -- (14.8, 18.5);
\foreach \x in \xrange
{\draw[ultra thin] (\x, 0) -- (\x, 20.97);}
\foreach \x in \xrangeR{% {14.6,14.2,...,8.6}{
\node at (\x, 18.35) {\tiny\sc};
\node [rotate=90, anchor=west] at (\x, 18.5) {\tiny\dy};
\node [rotate=90, anchor=east] at (\x, 19.7) {\small\ttfamily\dm};
\node at (\x, 19.75) {{\tiny\ttfamily\AdvanceDate[1]\the\day\global\count3=\month}};
\node [rotate=90, anchor=east]at (\x, 20.3) {\tiny\ttfamily\emn};
\node [rotate=90, anchor=west]at (\x, 20.2) {\tiny\ttfamily\edy};
\node [anchor=east] at ($(7.5, 20.2)+(\tshift,0)$) {\hboxR{\mn\space \thisyear}};
\node [anchor=west] at (.35, 20.2) {\lr{\scshape\mnp{}
\ifnum\monthname>9 \the\numexpr\year+1\relax\else\the\year\fi}};
}
\foreach \x/\y in \ntep%{8.6/next week, 8.2/task|event, 7.8/purchase}
\node at (\x, 19.5) [rotate=90] {\ttfamily \small\y};
\end{tikzpicture}%
\ifoddpage\global\oddpagefalse\else\global\oddpagetrue\fi
}\global\advance\monthname by 1\relax}%
}
\makeatother
\parindent=0pt
\pagestyle{empty}
\begin{document}
% \yearlytodo{1400}% first day of 1400 is Sunday
% \yearlytodo{1401}% first day of 1401 is Monday
% \yearlytodo{1402}% first day of 1402 is Tuesday
\yearlytodo{1403}% first day of 1401 is Wednesday
% \yearlytodo{1404}% first day of 1402 is Friday
\end{document}