Post by Dr Eberhard W LisseWäre das nicht etwas für Lua(TeX)?
...
Danke für die Antwort, die mich auf die Idee brachte, zum ersten Mal
ChatGPT zu befragen, und tatsächlich erhielt ich korrigierten Code.
%%%%%%%%%%%%% Funktionierendes Minimalbeispiel %%%%%%%%%%%%%%%%
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calendar,fpu,calc}
\newcommand\mond[4] % center, radius, color, rotation (-180,...,180),
{%
\ifnum #4 > 0
\pgfmathsetmacro\lb{ #2} % left arc, horizontal axis
\pgfmathsetmacro\rb{ #2*(90-#4)/90} % right arc, horizontal axis
\else
\pgfmathsetmacro\lb{-#2*(90+#4)/90} % left arc, horizontal axis
\pgfmathsetmacro\rb{-#2} % right arc, horizontal axis
\fi
\draw[thick,#3,fill=white] #1 circle (#2);
\fill[#3,opacity=0.5] ($#1+(0,#2)$) arc (90:270:\lb cm and #2 cm)
arc (270:90:\rb cm and #2 cm);
}
\tikzset{
moon colour/.style={
moon fill/.style={
fill=#1
}
},
sky colour/.style={
sky draw/.style={
draw=#1
},
sky fill/.style={
fill=#1
}
},
southern hemisphere/.style={
rotate=180
}
}
\makeatletter
\pgfcalendardatetojulian{2023-11-13}{\***@pgf@counta} % 2010-01-15 07:11
UTC -- http://aa.usno.navy.mil/cgi-bin/aa_moonphases.pl?year=2010&ZZZ=END
\def\synodicmonth{29.530588853}
\newcommand{\moon}[2][]{%
\edef\checkfordate{\noexpand\in@{-}{#2}}%
\checkfordate%
\ifin@%
\pgfcalendardatetojulian{#2}{\***@pgf@countb}%
\pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro\dayssincenewmoon{\the\***@pgf@countb-\the\***@pgf@counta-(7/24+11/(24*60))}%
\pgfmathsetmacro\lunarage{mod(\dayssincenewmoon,\synodicmonth)}
\pgfkeys{/pgf/fpu=false}%%
\else%
\def\lunarage{#2}%
\fi%
%% auskommentiert, hier waren die Tage nach Neumond spiegelverkehrt %%
%
%
\pgfmathsetmacro\leftside{ifthenelse(\lunarage<=\synodicmonth/2,cos(360*(\lunarage/\synodicmonth)),1)}%
%
\pgfmathsetmacro\rightside{ifthenelse(\lunarage<=\synodicmonth/2,-1,-cos(360*(\lunarage/\synodicmonth))}%$
%
%%%%%%%% korrigierte zwei Zeilen ifthenelse von ChatGPT
%%%%%%%%%%%%%%%%%%%%%%
\pgfmathsetmacro\leftside{ifthenelse(\lunarage<=\synodicmonth/2,cos(360*(\lunarage/\synodicmonth)),ifthenelse(\lunarage<=\synodicmonth,-1,1))}
\pgfmathsetmacro\rightside{ifthenelse(\lunarage<=\synodicmonth/2,1,ifthenelse(\lunarage<=\synodicmonth,-cos(360*(\lunarage/\synodicmonth)),1))}
\tikz [moon colour=white,sky colour=black,#1]{
\draw [moon fill, sky draw] (0,0) circle [radius=1ex];
\draw [sky draw, sky fill] (0,1ex)
arc (90:-90:\rightside ex and 1ex)
arc (-90:90:\leftside ex and 1ex)
-- cycle;
}%
}
\makeatother
\newcommand{\newmoon}{\moon{0}}
\newcommand{\waxingcrescent}{\moon{\synodicmonth/8}}
\newcommand{\firstquartermoon}{\moon{2*\synodicmonth/8}}
\newcommand{\waxinggibbous}{\moon{3*\synodicmonth/8}}
\newcommand{\fullmoon}{\moon{4*\synodicmonth/8}}
\newcommand{\waninggibbous}{\moon{5*\synodicmonth/8}}
\newcommand{\thirdquartermoon}{\moon{6*\synodicmonth/8}}
\newcommand{\waningcrescent}{\moon{7*\synodicmonth/8}}
\begin{document}\noindent\raggedleft%
%% Tage nach dem Neumond erscheinen nicht mehr spiegelverkehrt %%%%%
\foreach \d in {1,2,...,30}{%
\d: \moon{\year-11-\d} \ }
\end{document}