summaryrefslogtreecommitdiff
path: root/language/japanese/BX/bxjaholiday/bxjaholiday.tex
blob: a647083e938d7d2b376e5c5de26fb2c5c56863c1 (plain)
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
% +++
% latex = "xelatex"
% extra_clean_files = [
%   "%B.synctex.gz", "%B.hd", "%B.glo"
% ]
% +++
\RequirePackage{fontspec}
\documentclass{l3doc}

% packages
\usepackage{bxjaholiday}
\usepackage{caption}

% fonts
\newfontfamily{\fIpaex}{IPAexMincho}[Scale=0.95]
\newcommand*{\Ja}[1]{{\fIpaex#1}}

% logos
\usepackage{bxtexlogo}
\bxtexlogoimport{*}

% syntax
\newenvironment{code}{\quote\small}{\endquote}

% cross-refs
\usepackage{wtref}
\newref{tab,sec}

% macros
\newcommand{\PkgName}{\pkg{bxjaholiday}}
\newcommand{\Ie}{i.\,e.}
\newcommand{\Eg}{e.\,g.}

\ExplSyntaxOn
\cs_set_eq:NN \_ \c_underscore_str
\cs_new:Npn \__bxjh_doc_holiday_line:nn #1#2
  {
    % first column: holiday
    #1 &
    % second column: variable
    \cs { g_bxjh_#2_tl } &
    % third column: Name in Japanese
    \Ja { \tl_use:c { g_bxjh_#2_tl } } \\
  }
\cs_new:Npn \__bxjh_doc_week_of_day_line:nn #1#2
  {
    % first column: week of day
    #1 &
    % second column: int variable
    \cs { c_bxjh_ \tl_lower_case:n{ #1 } _int } &
    % third column: int value
    \int_use:c { c_bxjh_ \tl_lower_case:n{ #1 } _int } &
    % fourth column: tl variable
    \cs { g_bxjh_#2_tl } &
    % fifth column: tl value
    \Ja { \tl_use:c { g_bxjh_#2_tl } } \\
  }
\cs_new_eq:NN \HolidayLine \__bxjh_doc_holiday_line:nn
\cs_new_eq:NN \WeekofdayLine \__bxjh_doc_week_of_day_line:nn
\ExplSyntaxOff

% metadata
\GetFileInfo{\jobname.sty}
\title{The {\PkgName} package}
\author{Takuto ASAKURA (wtsnjp)}
\date{\fileversion \quad [\filedate]}

\begin{document}

\maketitle

\begin{abstract}
This package provides a command to convert dates to names of Japanese holidays
(\emph{shukujitsu}; \Ja{祝日}). For internal use, I need to implement a
function to judge the day of week (\emph{youbi}; \Ja{曜日}), so a command
converting dates to \emph{youbi} in the same manner is also available as a free
gift. The equivalent functions and further (lower-level) APIs are provided for
expl3.
%All {\LaTeXe} and expl3 interfaces are (first-)fully expandable, so
%those could be used almost anywhere in your documents.
\end{abstract}

%\tableofcontents

\begin{documentation}

%\section{Introduction}

\section{System requirements}

As one of the BX series\footnote{BX series is a collection of {\LaTeX} packages
mainly developed by Takayuki YATO (a.k.a.~ZR.) ``BX'' stands for
``\underline{b}abel e\underline{x}tensions'' and packages in this series
normally support various {\TeX} engines not only Japanese-specific ones
({\pTeX}, {\upTeX}, and so on.)} packages, {\PkgName} supports all {\TeX}
engines which supported by expl3 (\Ie, the {\eTeX} extension is required.)
Specifically, following {\TeX} systems are supported:
%
\begin{itemize}
\item {\TeX} format: {\LaTeXe}.
\item {\TeX} engine: {\pdfTeX}, {\XeTeX}, {\LuaTeX},\footnote{Note that if you
want to print Japanese characters with {\TeX} engines which is not specifically
designed for Japanese, you need to setup proper fonts and other things.}
{\pTeX}, and {\upTeX}.
\end{itemize}

\section{Loading the package}

The package should be loaded in the usual {\LaTeXe} way. No package option is
available.
%
\begin{code}
|\usepackage{bxjaholiday}|
\end{code}

\section{{\LaTeXe} interfaces}

\begin{function}[EXP]{\jaholidayname}
\begin{syntax}
|\jaholidayname|\marg{year}\marg{month}\marg{day}
\end{syntax}
%
This command is expanded to the name of Japanese holiday corresponding to the
specified date, if it is a holiday. For a date which is not a holiday, it will
be expanded to nothing (an empty token.) See Table~\tabref{holidays} for all
possible results.

For \meta{year}, \meta{month}, and \meta{day}, you can explicitly write
numbers, or use counters, \Eg, |\year|, |\month|, and |\day|. To be exact,
those could be any \meta{integer expression}.
\end{function}

\begin{function}[EXP]{\jadayofweek}
\begin{syntax}
|\jadayofweek|\marg{year}\marg{month}\marg{day}
\end{syntax}
%
This command converts from a date to the name of week, \Ie, one of \Ja{月, 火,
水, 木, 金, 土, 日}. You can specify the arguments in exactly the same way as
|\jaholidayname|.
\end{function}

\begin{function}[EXP]{\IfJaHolidayTF,\IfJaHolidayT,\IfJaHolidayF}
\begin{syntax}
|\IfJaHolidayTF|\marg{year}\marg{month}\marg{day}\marg{true code}\marg{false code}
|\IfJaHolidayT|\marg{year}\marg{month}\marg{day}\marg{true code}
|\IfJaHolidayF|\marg{year}\marg{month}\marg{day}\marg{false code}
\end{syntax}
%
The |\IfJaHoliday(TF)| tests are used to check if a date is a Japanese holiday
or not. Note that substitute holidays (\Ja{振替休日}) are also judged as a
holiday in this test.
\end{function}

\section{expl3 interfaces}

All expl3 interfaces provided by {\PkgName} belong to the \texttt{bxjh} module.

\subsection{Functions}

\begin{function}[EXP]{\bxjh_holiday_name:nnn}
\begin{syntax}
|\bxjh_holiday_name:nnn| \marg{year} \marg{month} \marg{day}
\end{syntax}
%
This is expl3 version of |\jaholidayname|. It converts dates into Japanese
holiday names.
\end{function}

\begin{function}[EXP]{\bxjh_day_of_week_name:nnn,\bxjh_day_of_week:nnn}
\begin{syntax}
|\bxjh_day_of_week_name:nnn| \marg{year} \marg{month} \marg{day}
|\bxjh_day_of_week:nnn| \marg{year} \marg{month} \marg{day}
\end{syntax}
%
|\bxjh_day_of_week_name:nnn| is an expl3 version of |\jadayofweek|. It converts
a date into day of week in Japanese. To use that information in expl3, \Eg, for
branching, |\bxjh_day_of_week:nnn| is more suitable. It returns an internal
\texttt{int} value, so you can compare those results with the constants provided
by this package. See Section~\secref{variables}.
\end{function}

\begin{function}[EXP,TF]{\bxjh_if_holiday:nnn}
\begin{syntax}
|\bxjh_if_holiday:nnnTF| \marg{year} \marg{month} \marg{day} \marg{true code} \marg{false code}
\end{syntax}
%
This test is expl3 version of |\IfJaHoliday(TF)|.
\end{function}

\begin{function}[EXP]{\bxjh_apply_prev_day:Nnnn,\bxjh_apply_next_day:Nnnn}
\begin{syntax}
|\bxjh_apply_prev_day:Nnnn| \meta{function} \marg{year} \marg{month} \marg{day}
|\bxjh_apply_next_day:Nnnn| \meta{function} \marg{year} \marg{month} \marg{day}
\end{syntax}
%
These functions get previous/next day of the specified date, and apply it to
the specified \meta{function}. The \meta{function} must take three arguments in
the order. For example,
%
\begin{code}
|\bxjh_apply_next_day:Nnnn \bxjh_holiday_name:nnn { 2019 } { 12 } { 31 }|
\end{code}
%
produces the result of:
%
\begin{code}
|\bxjh_holiday_name:nnn { 2020 } { 1 } { 1 }|
\end{code}
\end{function}

\subsection{Variables and constants}\seclabel{variables}

\paragraph{Names of Japanese holidays}

All of them are provided as global \texttt{tl} variables. See
Table~\tabref{holidays}.
%
\begin{table}[p]
\centering\small
\caption{Japanese holidays}
\tablabel{holidays}
\begin{tabular}{lll}
\hline
Holiday & Variable & Name in Japanese \\ \hline
\HolidayLine{New Year's Day}{ganjitsu}
\HolidayLine{Coming of Age Day}{seijin}
\HolidayLine{National Foundation Day}{kenkoku}
\HolidayLine{The Emperor's Birthday}{tennou}
\HolidayLine{Vernal Equinox Day}{shunbun}
\HolidayLine{Showa Day}{showa}
\HolidayLine{Greenery Day}{midori}
\HolidayLine{Constitution Memorial Day}{kenpou}
\HolidayLine{National Holiday}{kokumin}
\HolidayLine{Children's Day}{kodomo}
\HolidayLine{(substitute holiday)}{furikae}
\HolidayLine{Marine Day}{umi}
\HolidayLine{Mountain Day}{yama}
\HolidayLine{Autumnal Equinox Day}{shubun}
\HolidayLine{Respect for the Aged Day}{keirou}
\HolidayLine{Sports Day}{sports}
\HolidayLine{Health and Sports Day}{taiiku}
\HolidayLine{Culture Day}{bunka}
\HolidayLine{Labor Thanksgiving Day}{kinrou}
\HolidayLine{National Mourning of Showa}{showa\_taisou}
\HolidayLine{National Wedding of Akihito}{akihito\_kekkon}
\HolidayLine{National Wedding of Naruhito}{naruhito\_kekkon}
\HolidayLine{Core Enthronement Ceremony}{sokuirei}
\HolidayLine{Coronation Day}{sokui}
\hline
\end{tabular}
\end{table}

\paragraph{Day of week}

\enlargethispage{5mm}

Internally, {\PkgName} uses integers to represent day of week, and corresponding
\texttt{int} constants are defined. In addition to that, Japanese names of those
are also provided as global \texttt{tl} variables. See
Table~\tabref{dayofweek}.
%
\begin{table}[p]
\centering\small
\caption{Day of week}
\tablabel{dayofweek}
\begin{tabular}{l|lr|ll}
\hline
Day of week & Constant (\texttt{int}) & & Variable (\texttt{tl}) & \\ \hline
\WeekofdayLine{Monday}{getsu}
\WeekofdayLine{Tuesday}{ka}
\WeekofdayLine{Wednesday}{sui}
\WeekofdayLine{Thursday}{moku}
\WeekofdayLine{Friday}{kin}
\WeekofdayLine{Saturday}{do}
\WeekofdayLine{Sunday}{nichi}
\hline
\end{tabular}
\end{table}

\end{documentation}

%\PrintChanges

\end{document}
% vim: spell: