# pgfgantt: Start the week on Sunday?

I want my Gantt chart to display with the week starting on Sunday. You can see this in the second gantt chart in the MWE. How do I accomplish that without explicitly writing out each week?

My use case is for project management and the work week starts on Sunday.

Minimum Working Example

\documentclass[a4paper]{article}
\usepackage{pgfgantt}

\begin{document}

\begin{ganttchart}[
hgrid,
vgrid,
x unit = 1cm,
time slot format=isodate
]{2022-06-19}{2022-07-01}
\gantttitlecalendar{year, month, week, day, weekday=shortname} \\
\end{ganttchart}

\begin{ganttchart}[
hgrid,
vgrid,
x unit = 1cm,
time slot format=isodate
]{2022-06-19}{2022-07-01}
\gantttitlecalendar{year, month} \\
\gantttitle{Week 1}{7}
\gantttitle{Week 2}{6} \\
\gantttitlecalendar{day, weekday=shortname} \\
\end{ganttchart}

\end{document}


The ideal solution would be to have an option to switch the week day start from meaning Monday to Sunday. But I think that's hard coded. I have checked the TikZ manual's relevant sections (89.1.3 Typesetting Dates) and didn't find anything that helps me.

The only other question that mentions a similar topic is Tikz calendar with week starting on Sunday but it was unhelpful because it didn't modify when the week started and does not use pgfgantt.

New contributor
adham327 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Welcome to TeX.se and thanks for adding a minimal example document to your question! Jun 21 at 12:43

The start day is indeed hard coded but it's not too difficult to change. The original calendar/week/.code uses Sunday in the \ifdate{} part of the code. We simply need to change this to Saturday to have weeks begin on Sunday. I don't know if the package author would be open to feature requests, but this would be a very simple addition to make to allow a different start day.

\documentclass[a4paper]{article}
\usepackage{pgfgantt}
\makeatletter
\ganttset{
calendar/week/.code={%
\ifgtt@calendar@eol\ganttnewline\fi%
\begingroup%
\gtt@calendar@slots=1\relax%
\gtt@calendar@weeknumber=#1\relax%
\pgfcalendar{}{\gtt@calendar@startdate}{\gtt@calendar@enddate}{%
\ifdate{Saturday}{%
\gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax%
\pgfcalendarjuliantodate{\gtt@calendar@startofweek}%
{\startyear}{\startmonth}{\startday}%
\def\currentweek{\the\gtt@calendar@weeknumber}%
\gantttitle{%
\ganttvalueof{calendar week text}%
}{%
\the\gtt@calendar@slots%
}%
\gtt@calendar@slots=1\relax%
}{%
}%
\ifdate{equals=\pgfcalendarendiso}{%
\ifnum\gtt@calendar@slots=1\relax\else%
\gtt@calendar@startofweek=\pgfcalendarcurrentjulian\relax%
\pgfcalendarjuliantodate{\gtt@calendar@startofweek}%
{\startyear}{\startmonth}{\startday}%
\def\currentweek{\the\gtt@calendar@weeknumber}%
\gantttitle{%
\ganttvalueof{calendar week text}%
}{%
\the\gtt@calendar@slots%
}%
\fi%
}{}%
}%
\endgroup%
\gtt@calendar@eoltrue%
}
}
\makeatother
\begin{document}

\begin{ganttchart}[
hgrid,
vgrid,
x unit = 1cm,
time slot format=isodate
]{2022-06-19}{2022-07-01}
\gantttitlecalendar{year, month, week, day, weekday=shortname} \\
\end{ganttchart}

\end{document}