Commit ed59d38e authored by Vít Novotný's avatar Vít Novotný
Browse files

Added the `\thesis@seasonYear` macro along with unit tests.

Unlike `\thesis@year`, `\thesis@seasonYear` takes into account the
fact that January and Fabruary of the year N still belong to the
fall semester of the year N-1.
parent cc896c12
Loading
Loading
Loading
Loading
+27 −5
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
\usepackage{microtype}
\usepackage{microtype}
\usepackage{ragged2e}
\usepackage{ragged2e}
\usepackage{paralist}
\usepackage{paralist}
\usepackage{multicol}


% Making paragraphs numbered
% Making paragraphs numbered
\makeatletter
\makeatletter
@@ -51,11 +52,15 @@
%<*class>
%<*class>
\NeedsTeXFormat{LaTeX2e}
\NeedsTeXFormat{LaTeX2e}
% Define `\thesis@version` and store it in the `VERSION.tex` file \fi
% Define `\thesis@version` and store it in the `VERSION.tex` file \fi
\def\thesis@version{2015/12/09 v0.3.29 fithesis3 MU thesis class}
\def\thesis@version{2015/01/05 v0.3.30 fithesis3 MU thesis class}
% {\newwrite\f\openout\f=VERSION\write\f{\thesis@version}\closeout\f}
% {\newwrite\f\openout\f=VERSION\write\f{\thesis@version}\closeout\f}
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% \changes{v0.3.30}{2015/01/05}{The \cs{thesis@seasonYear} macro
%   has been added, which, unlike \cs{thesis@year} takes into
%   account the fact that January and Fabruary of the year $n$
%   still belong to the fall semester of the year $n-1$.}
% \changes{v0.3.29:3}{2015/12/09}{The \texttt{table} class option
% \changes{v0.3.29:3}{2015/12/09}{The \texttt{table} class option
%   for the style files of the Masaryk University in Brno now loads
%   for the style files of the Masaryk University in Brno now loads
%   all the required packages and changes the table measurements
%   all the required packages and changes the table measurements
@@ -876,21 +881,31 @@
% stands for day. The \textit{date} is parsed and stored using
% stands for day. The \textit{date} is parsed and stored using
% the \DescribeMacro{\thesis@parseDate}|\thesis@parseDate|
% the \DescribeMacro{\thesis@parseDate}|\thesis@parseDate|
% macro within the following macros:
% macro within the following macros:
% \begin{multicols}{2}
% \begin{itemize}
% \begin{itemize}
%   \item\DescribeMacro{\thesis@date}|\thesis@date| -- The entire
%   \item\DescribeMacro{\thesis@date}|\thesis@date| -- The entire
%     \textit{date}
%     \textit{date}
%   \item\DescribeMacro{\thesis@year}|\thesis@year| -- The
%   \item\DescribeMacro{\thesis@year}|\thesis@year| -- The
%     \texttt{YYYY} part of \textit{date}
%     \texttt{YYYY} of \textit{date}
%   \item\DescribeMacro{\thesis@month}|\thesis@month| -- The
%   \item\DescribeMacro{\thesis@month}|\thesis@month| -- The
%     \texttt{MM} part of \textit{date}
%     \texttt{MM} of \textit{date}
%   \item\DescribeMacro{\thesis@day}|\thesis@day| -- The
%   \item\DescribeMacro{\thesis@day}|\thesis@day| -- The
%     \texttt{DD} part of \textit{date}
%     \texttt{DD} of \textit{date}
% \end{itemize}
% \end{multicols}
% \begin{itemize}
%   \item\DescribeMacro{\thesis@season}|\thesis@season| -- Expands
%   \item\DescribeMacro{\thesis@season}|\thesis@season| -- Expands
%     to either:
%     to either:
%     \begin{itemize}
%     \begin{itemize}
%       \item\texttt{spring} if $2<{}$\texttt{MM}${}<9$,
%       \item\texttt{spring} if $2<{}$\texttt{MM}${}<9$,
%       \item\texttt{fall} if \texttt{MM}${}\leq2$ or \texttt{MM}${}\geq9$.
%       \item\texttt{fall} if \texttt{MM}${}\leq2$ or \texttt{MM}${}\geq9$.
%     \end{itemize}
%     \end{itemize}
%   \item\DescribeMacro{\thesis@seasonYear}|\thesis@seasonYear|
%     -- The year of the given semester:
%     \begin{itemize}
%       \item\texttt{YYYY}${}-1$ if \texttt{MM}${}\leq2$.
%       \item\texttt{YYYY} if \texttt{MM}${}>2$
%     \end{itemize}
%   \item\DescribeMacro{\thesis@academicYear}|\thesis@academicYear|
%   \item\DescribeMacro{\thesis@academicYear}|\thesis@academicYear|
%     -- The academic year of the given semester:
%     -- The academic year of the given semester:
%     \begin{itemize}
%     \begin{itemize}
@@ -921,11 +936,18 @@
  \ifnum\@month>8%
  \ifnum\@month>8%
                    \edef\@yearA{\the\@year}%
                    \edef\@yearA{\the\@year}%
    \advance\@year 1\edef\@yearB{\the\@year}%
    \advance\@year 1\edef\@yearB{\the\@year}%
    \advance\@year-1
  \else
  \else
    \advance\@year-1\edef\@yearA{\the\@year}%
    \advance\@year-1\edef\@yearA{\the\@year}%
    \advance\@year 1\edef\@yearB{\the\@year}%
    \advance\@year 1\edef\@yearB{\the\@year}%
  \fi
  \fi
  \global\edef\thesis@academicYear{\@yearA/\@yearB}}}
  \global\edef\thesis@academicYear{\@yearA/\@yearB}
  
  % Set the season year
  \ifnum\@month>2\else
    \advance\@year-1
  \fi
  \global\edef\thesis@seasonYear{\the\@year}}}


\edef\thesis@date{\the\year/\the\month/\the\day}%
\edef\thesis@date{\the\year/\the\month/\the\day}%
\expandafter\thesis@parseDate\thesis@date|%
\expandafter\thesis@parseDate\thesis@date|%
+2 −2
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@
% This is the base file of the Czech locale.\iffalse
% This is the base file of the Czech locale.\iffalse
%<*base>
%<*base>
% \fi\begin{macrocode}
% \fi\begin{macrocode}
\ProvidesFile{fithesis/locale/fithesis-czech.def}[2015/11/29]
\ProvidesFile{fithesis/locale/fithesis-czech.def}[2016/01/05]
%    \end{macrocode}
%    \end{macrocode}
% The locale file defines all the private macros mandated by the
% The locale file defines all the private macros mandated by the
% locale file interface.
% locale file interface.
@@ -41,7 +41,7 @@
\gdef\thesis@czech@spring{jaro}
\gdef\thesis@czech@spring{jaro}
\gdef\thesis@czech@fall{podzim}
\gdef\thesis@czech@fall{podzim}
\gdef\thesis@czech@semester{%
\gdef\thesis@czech@semester{%
  \thesis@{czech@\thesis@season} \thesis@year}
  \thesis@{czech@\thesis@season} \thesis@seasonYear}
\gdef\thesis@czech@typeName{%
\gdef\thesis@czech@typeName{%
  \ifx\thesis@type\thesis@bachelors%
  \ifx\thesis@type\thesis@bachelors%
    Bakalářská práce%
    Bakalářská práce%
+2 −2
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@
% This is the base file of the English locale.\iffalse
% This is the base file of the English locale.\iffalse
%<*base>
%<*base>
% \fi\begin{macrocode}
% \fi\begin{macrocode}
\ProvidesFile{fithesis/locale/fithesis-english.def}[2015/11/29]
\ProvidesFile{fithesis/locale/fithesis-english.def}[2015/01/05]
%    \end{macrocode}
%    \end{macrocode}
% The locale file defines all the private macros mandated by the
% The locale file defines all the private macros mandated by the
% locale file interface.
% locale file interface.
@@ -30,7 +30,7 @@
\gdef\thesis@english@spring{Spring}
\gdef\thesis@english@spring{Spring}
\gdef\thesis@english@fall{Fall}
\gdef\thesis@english@fall{Fall}
\gdef\thesis@english@semester{%
\gdef\thesis@english@semester{%
  \thesis@{english@\thesis@season} \thesis@year}
  \thesis@{english@\thesis@season} \thesis@seasonYear}
\gdef\thesis@english@typeName{%
\gdef\thesis@english@typeName{%
  \ifx\thesis@type\thesis@bachelors%
  \ifx\thesis@type\thesis@bachelors%
    Bachelor's Thesis%
    Bachelor's Thesis%
+2 −2
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@
% This is the base file of the Slovak locale.\iffalse
% This is the base file of the Slovak locale.\iffalse
%<*base>
%<*base>
% \fi\begin{macrocode}
% \fi\begin{macrocode}
\ProvidesFile{fithesis/locale/fithesis-slovak.def}[2015/11/29]
\ProvidesFile{fithesis/locale/fithesis-slovak.def}[2015/01/05]
%    \end{macrocode}
%    \end{macrocode}
% The locale file defines all the private macros mandated by the
% The locale file defines all the private macros mandated by the
% locale file interface.
% locale file interface.
@@ -41,7 +41,7 @@
\gdef\thesis@slovak@spring{jar}
\gdef\thesis@slovak@spring{jar}
\gdef\thesis@slovak@fall{jeseň}
\gdef\thesis@slovak@fall{jeseň}
\gdef\thesis@slovak@semester{%
\gdef\thesis@slovak@semester{%
  \thesis@{slovak@\thesis@season} \thesis@year}
  \thesis@{slovak@\thesis@season} \thesis@seasonYear}
\gdef\thesis@slovak@typeName{%
\gdef\thesis@slovak@typeName{%
  \ifx\thesis@type\thesis@bachelors%
  \ifx\thesis@type\thesis@bachelors%
    Bakalárska práca%
    Bakalárska práca%

test/parse-date.tex

0 → 100644
+40 −0
Original line number Original line Diff line number Diff line
\documentclass{fithesis3}
\thesissetup{autoLayout=false}
\begin{document}\makeatletter
  % Unit tests for the `\thesis@parseDate` function.
  \def\test#1#2#3#4#5#6#7{%
    \def\expected@date{#1}
    \def\expected@year{#2}
    \def\expected@month{#3}
    \def\expected@day{#4}
    \def\expected@season{#5}
    \def\expected@seasonYear{#6}
    \def\expected@academicYear{#7}
    \thesis@parseDate#1|
    \ifx\thesis@date\expected@date
    \ifx\thesis@year\expected@year
    \ifx\thesis@month\expected@month
    \ifx\thesis@day\expected@day
    \ifx\thesis@season\expected@season
    \ifx\thesis@seasonYear\expected@seasonYear
    \ifx\thesis@academicYear\expected@academicYear
    \else\errmessage{#1 @academicYear: \thesis@academicYear !=#7}\fi
    \else\errmessage{#1 @seasonYear: \thesis@seasonYear !=#6}\fi
    \else\errmessage{#1 @season: \thesis@season !=#5}\fi
    \else\errmessage{#1 @day: \thesis@day !=#4}\fi
    \else\errmessage{#1 @month: \thesis@month !=#3}\fi
    \else\errmessage{#1 @year: \thesis@year !=#2}\fi
    \else\errmessage{#1 @date: \thesis@date !=#1}\fi}
  \test{2015/01/01}{2015}{01}{01}{fall}{2014}{2014/2015}
  \test{2015/02/01}{2015}{02}{01}{fall}{2014}{2014/2015}
  \test{2015/03/01}{2015}{03}{01}{spring}{2015}{2014/2015}
  \test{2015/04/01}{2015}{04}{01}{spring}{2015}{2014/2015}
  \test{2015/05/01}{2015}{05}{01}{spring}{2015}{2014/2015}
  \test{2015/06/01}{2015}{06}{01}{spring}{2015}{2014/2015}
  \test{2015/07/01}{2015}{07}{01}{spring}{2015}{2014/2015}
  \test{2015/08/01}{2015}{08}{01}{spring}{2015}{2014/2015}
  \test{2015/09/01}{2015}{09}{01}{fall}{2015}{2015/2016}
  \test{2015/10/01}{2015}{10}{01}{fall}{2015}{2015/2016}
  \test{2015/11/01}{2015}{11}{01}{fall}{2015}{2015/2016}
  \test{2015/12/01}{2015}{12}{01}{fall}{2015}{2015/2016}
\makeatother\end{document}