Skip to content

Commit

Permalink
refactor: 修改日期字段的处理方式
Browse files Browse the repository at this point in the history
  • Loading branch information
atxy-blip committed May 17, 2023
1 parent 01235b1 commit 5fcd8ab
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 98 deletions.
2 changes: 1 addition & 1 deletion docs/njuthesis-setup.def
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
% 以下均为研究生项
%
% degree = {工程硕士},
% degree* = {Master of Engineering}
% degree* = {Master of Engineering},
% 覆盖默认学位名称
%
field = {物理化学},
Expand Down
153 changes: 56 additions & 97 deletions source/njuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -2738,10 +2738,10 @@ To produce the documentation run the original source files ending with
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\c_@@_today_tl}
% \begin{variable}{\c_@@_name_today_tl}
% 编译当天日期,格式为 |yyyy-mm-dd|。
% \begin{macrocode}
\tl_const:Nx \c_@@_today_tl
\tl_const:Nx \c_@@_name_today_tl
{
\int_to_arabic:n { \c_sys_year_int } -
\int_to_arabic:n { \c_sys_month_int } -
Expand Down Expand Up @@ -3187,34 +3187,23 @@ To produce the documentation run the original source files ending with
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_date:n,\@@_date_en:n}
% 从 ISO 格式的日期字符串生成中英文日期文本。
% \begin{macro}{\@@_date:nn}
% \begin{macrocode}
\cs_new_protected:Npn \@@_date:n #1 { \@@_date:nn {#1} { } }
\cs_new_protected:Npn \@@_date_en:n #1 { \@@_date:nn {#1} { _en } }
\cs_new:Npn \@@_date:nn { \@@_date:nnn { } }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\exp_last_unbraced:cV,\@@_date:nn}
% \begin{macro}{\@@_date:nnn}
% \changes{v0.20}{2022/05/24}{可在日期项留空以使用空白的年月日字样。}
% 用于日期格式转化的辅助命令。在传入的字符串为空时生成空白字样。
% \begin{macrocode}
\cs_generate_variant:Nn \exp_last_unbraced:NV { cV }
\cs_new_protected:Npn \@@_date:nn #1#2
\cs_new:Npn \@@_date:nnn #1#2#3
{
\tl_set:Nv \l_@@_tmpa_tl { g_@@_info_ #1 date_raw_tl }
\tl_new:c { g_@@_info_ #1 date #2 _tl }
\tl_set:cx { g_@@_info_ #1 date #2 _tl }
\tl_set:cx { g_@@_info_ #2 date #1 _tl }
{
\tl_if_empty:NTF \l_@@_tmpa_tl
{ \@@_name:n { blankdate #2 } }
% \end{macrocode}
% |w| 后的参数需要使用非括号包裹的形式完全展开。
% \begin{macrocode}
{
\exp_last_unbraced:cV { @@_date #2 :www }
\l_@@_tmpa_tl \q_stop
}
\tl_if_empty:nTF {#3}
{ \@@_name:n { blankdate #1 } }
{ \use:c { @@_date #1 :www } #3 \q_stop }
}
}
% \end{macrocode}
Expand Down Expand Up @@ -4457,43 +4446,7 @@ To produce the documentation run the original source files ending with
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/submit-date}
% \changes{v0.14}{2022/01/14}{精简提交日期选项。}
% 提交日期,初始值为编译当天日期。
% \begin{macrocode}
submit-date .tl_set:N = \g_@@_info_submitdate_raw_tl ,
submit-date .initial:V = \c_@@_today_tl ,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/defend-date}
% \changes{v0.14}{2022/01/14}{精简答辩日期选项。}
% 答辩日期。
% \begin{macrocode}
defend-date .tl_set:N = \g_@@_info_defenddate_raw_tl ,
defend-date .initial:V = \c_@@_today_tl ,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/defend-date}
% \changes{v0.19}{2022/05/23}{新增国家图书馆封面的学位授予日期设置项。}
% 学位授予日期。
% \begin{macrocode}
confer-date .tl_set:N = \g_@@_info_conferdate_raw_tl ,
confer-date .initial:V = \c_@@_today_tl ,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/bottom-date}
% \changes{v0.19}{2022/05/23}{新增国家图书馆封面的底部日期设置项。}
% 底部日期。
% \begin{macrocode}
bottom-date .tl_set:N = \g_@@_info_bottomdate_raw_tl ,
bottom-date .initial:V = \c_@@_today_tl ,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/defend-date,info/chairman,info/reviewer}
% \begin{macro}{info/chairman,info/reviewer}
% 答辩委员会信息。
% \begin{macrocode}
chairman .tl_set:N = \g_@@_info_chairman_tl ,
Expand Down Expand Up @@ -4545,9 +4498,42 @@ To produce the documentation run the original source files ending with
% 覆盖预定义的学位字段。
% \begin{macrocode}
degree .tl_set:N = \g_@@_info_degree_tl ,
degree* .tl_set:N = \g_@@_info_degree_en_tl
degree* .tl_set:N = \g_@@_info_degree_en_tl ,
% \end{macrocode}
% \end{macro}
%
% 提交日期,初始值为编译当天日期。
% \begin{macrocode}
}
% \end{macrocode}
%
% \changes{v1.3}{2023/05/18}{日期字段直接在输入键值时处理。}
%
% \begin{macro}{info/submit-date}
% \changes{v0.14}{2022/01/14}{精简提交日期选项。}
% \begin{macro}{info/defend-date}
% \changes{v0.14}{2022/01/14}{精简答辩日期选项。}
% \begin{macro}{info/confer-date}
% \changes{v0.19}{2022/05/23}{新增国家图书馆封面的学位授予日期设置项。}
% \begin{macro}{info/bottom-date}
% \changes{v0.19}{2022/05/23}{新增国家图书馆封面的底部日期设置项。}
% \begin{variable}{\g_@@_info_submitdate_tl,\g_@@_info_defenddate_tl,
% \g_@@_info_bottomdate_tl,\g_@@_info_conferdate_tl}
% 日期。
% \begin{macrocode}
\clist_map_inline:nn { submit, defend, confer, bottom }
{
\keys_define:nn { nju / info }
{
#1-date .code:n = \@@_date:nn {#1} {##1},
#1-date .initial:V = \c_@@_name_today_tl
}
}
% \end{macrocode}
% \end{variable}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% 将指定信息项归入 \opt{anonymous} 组,以在盲审模式下选择性屏蔽。
Expand Down Expand Up @@ -4586,49 +4572,23 @@ To produce the documentation run the original source files ending with
%</class>
% \end{macrocode}
%
% \begin{macrocode}
%<*(def-u|def-g|def-p)>
\ctex_at_end_preamble:n
{
% \end{macrocode}
% \begin{variable}{\g_@@_info_submitdate_tl}
% 将 ISO 格式的原始日期字符串格式化为中文日期表示。
% \begin{macrocode}
\@@_date:n { submit }
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{
% \g_@@_info_submitdate_en_tl,
% \g_@@_info_defenddate_tl}
% 英文提交日期以及答辩日期仅用于研究生封面。
% \begin{variable}{\g_@@_info_submitdate_en_tl}
% 研究生封面额外需要英文日期。
% \begin{macrocode}
%<*def-g>
\@@_date_en:n { submit }
\@@_date:n { defend }
\cs_set:Npn \@@_date:nn #1#2
{ \@@_date:nnn { } {#1} {#2} \@@_date:nnn { _en } {#1} {#2} }
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{
% \g_@@_info_bottomdate_tl,
% \g_@@_info_conferdate_tl,
% \g_@@_info_confer_tl}
% 底部日期以及学位授予日期仅用于国家图书馆封面。
% \begin{variable}{\g_@@_info_confer_tl}
% \begin{macrocode}
\bool_if:NT \g_@@_opt_nlcover_bool
{
\@@_date:n { bottom }
\@@_date:n { confer }
\tl_new:N \g_@@_info_confer_tl
\tl_set:Nn \g_@@_info_confer_tl
{
\textbf { \c_@@_name_nju_tl } \hfil
\g_@@_info_conferdate_tl
}
}
%</def-g>
\tl_new:N \g_@@_info_confer_tl
\tl_set:Nn \g_@@_info_confer_tl
{
\textbf { \c_@@_name_nju_tl } \hfil
\g_@@_info_conferdate_tl
}
%</(def-u|def-g|def-p)>
% \end{macrocode}
% \end{variable}
%
Expand All @@ -4638,7 +4598,6 @@ To produce the documentation run the original source files ending with
% \begin{variable}{\g_@@_info_type_tl}
% 文档类型字样。
% \begin{macrocode}
%<*def-g>
\tl_new:N \g_@@_info_type_tl
\tl_set:Nx \g_@@_info_type_tl
{ \clist_item:Nn \c_@@_name_type_clist { \g_@@_info_type_int } }
Expand Down Expand Up @@ -7086,7 +7045,7 @@ To produce the documentation run the original source files ending with
\c_@@_name_ida_tl & \g_@@_info_id_tl &
\c_@@_name_depta_tl & \g_@@_info_dept_tl &
\c_@@_name_year_tl &
\tl_range:Nnn \g_@@_info_submitdate_raw_tl {1} {4} \\
\tl_range:Nnn \g_@@_info_submitdate_tl {1} {4} \\
\c_@@_name_degreea_tl &
{
\@@_degree_checkbox:Nn \c_true_bool { 2 } 学术学位硕士 \qquad
Expand Down

0 comments on commit 5fcd8ab

Please sign in to comment.