diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty | 120 |
1 files changed, 80 insertions, 40 deletions
diff --git a/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty b/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty index 3945d1cfc98..9a7b55f861c 100644 --- a/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty +++ b/Master/texmf-dist/tex/latex/zhnumber/zhnumber.sty @@ -6,26 +6,31 @@ %% %% zhnumber.dtx (with options: `package') %% -%% Copyright (C) 2012, 2014-2016 by Qing Lee <sobenlee@gmail.com> +%% Copyright (C) 2012, 2014-2016 by Qing Lee <sobenlee@gmail.com> %% -------------------------------------------------------------------------- -%% This work may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3 -%% of this license or (at your option) any later version. -%% The latest version of this license is in -%% http://www.latex-project.org/lppl.txt -%% and version 1.3 or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. %% -%% This work has the LPPL maintenance status "maintained". -%% The Current Maintainer of this work is Qing Lee. +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any later +%% version. This version of this license is in +%% http://www.latex-project.org/lppl/lppl-1-3c.txt +%% and the latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Qing Lee. +%% +%% -------------------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: zhnumber.dtx 9686fd1 2016-02-02 16:55:41 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: zhnumber.dtx e19bfb4 2016-05-14 12:23:34 +0800 Qing Lee <sobenlee@gmail.com> $ {Typesetting numbers with Chinese glyphs} -\ProvidesExplPackage - {\ExplFileName} - {\ExplFileDate}{2.3}{\ExplFileDescription} +\ProvidesExplPackage{\ExplFileName} + {\ExplFileDate}{2.4}{\ExplFileDescription} \msg_new:nnn { zhnumber } { l3-too-old } { Support~package~'expl3'~too~old. \\\\ @@ -135,6 +140,7 @@ } } \cs_generate_variant:Nn \zhnum_int:n { c } +\cs_new_nopar:Npn \@zhnum { \zhnum_int:n } \cs_new:Npn \zhnum_integer:n #1 { \exp_after:wN \__zhnum_read_integer:www @@ -282,6 +288,27 @@ } \int_compare:nNnF {#4} = \c_zero { \zhnum_digit_map:n {#4} } } +\DeclareExpandableDocumentCommand \zhdig { +o +m } + { + \IfNoValueTF {#1} + { \zhnum_digits_counter:n } + { \zhdigwithoptions {#1} } + {#2} + } +\NewDocumentCommand \zhdigwithoptions { +m +m } + { + \group_begin: + \keys_set:nn { zhnum / options } {#1} + \zhnum_digits_counter:n #1 {#2} + \group_end: + } +\cs_new:Npn \zhnum_digits_counter:n #1 + { + \int_if_exist:cTF { c@#1 } + { \zhnum_digits_null:v { c@#1 } } + { \__zhnum_counter_error:n {#1} } + } +\cs_new_nopar:Npn \@zhdig #1 { \zhnum_digits_null:f { \int_eval:n {#1} } } \DeclareExpandableDocumentCommand \zhdigits { +s +o +m } { \IfNoValueTF {#2} @@ -300,7 +327,7 @@ { \zhnum_digits:Nn \BooleanTrue } \cs_new_nopar:Npn \zhnum_digits_null:n { \zhnum_digits:Nn \BooleanFalse } -\cs_generate_variant:Nn \zhnum_digits_null:n { V } +\cs_generate_variant:Nn \zhnum_digits_null:n { V , v , f } \cs_new:Npn \zhnum_digits:Nn #1#2 { \exp_after:wN \__zhnum_read_digits:w @@ -356,19 +383,24 @@ { \__zhnum_week_day:www #2 \q_stop } } \cs_new:Npn \__zhnum_date:www #1/#2/#3 \q_stop + { \__zhnum_date_aux:nnn {#1} {#2} {#3} } +\cs_new_nopar:Npn \zhtoday + { \__zhnum_date_aux:Vnn \tex_year:D \tex_month:D \tex_day:D } +\cs_new_nopar:Npn \__zhnum_date_aux:nnn { - \zhnum_check_time:Nn \zhnum_digits_null:n {#1} \c__zhnum_year_tl - \zhnum_check_time:Nn \zhnum_int:n {#2} \c__zhnum_month_tl - \zhnum_check_time:Nn \zhnum_int:n {#3} \c__zhnum_day_tl + \bool_if:NTF \l__zhnum_time_bool + { \__zhnum_date_aux:NNnnnn \zhnum_digits_null:n \zhnum_int:n { } } + { \__zhnum_date_aux:Nnnnn \int_to_arabic:n { \l__zhnum_arabic_sep_tl } } } -\cs_new_nopar:Npn \zhtoday +\cs_new:Npn \__zhnum_date_aux:Nnnnn #1 + { \__zhnum_date_aux:NNnnnn #1#1 } +\cs_new:Npn \__zhnum_date_aux:NNnnnn #1#2#3#4#5#6 { - \zhnum_check_time:Nn \zhnum_digits_null:V \tex_year:D \c__zhnum_year_tl - \zhnum_check_time:Nn \zhnum_int:n \tex_month:D \c__zhnum_month_tl - \zhnum_check_time:Nn \zhnum_int:n \tex_day:D \c__zhnum_day_tl + #1 {#4} #3 \c__zhnum_year_tl #3 + #2 {#5} #3 \c__zhnum_month_tl #3 + #2 {#6} #3 \c__zhnum_day_tl } -\cs_new:Npn \zhnum_check_time:Nn #1 - { \bool_if:NTF \l__zhnum_time_bool {#1} { \int_to_arabic:n } } +\cs_generate_variant:Nn \__zhnum_date_aux:nnn { V } \cs_new:Npn \zhweekday #1 { \__zhnum_week_day:www #1 \q_stop } \cs_new:Npn \__zhnum_week_day:www #1/#2/#3 \q_stop @@ -433,16 +465,23 @@ { \cs_new:Npn \exp_not:N \__zhnum_time:ww ##1 \c_colon_str ##2 \exp_not:N \q_stop } + { \__zhnum_time_aux:nn {#1} {#2} } +\cs_new_nopar:Npn \zhcurrtime { - \zhnum_check_time:Nn \zhnum_int:n {#1} \c__zhnum_hour_tl - \zhnum_check_time:Nn \zhnum_int:n {#2} \c__zhnum_minute_tl + \__zhnum_time_aux:nn + { \int_div_truncate:nn \tex_time:D { 60 } } + { \int_mod:nn \tex_time:D { 60 } } } -\cs_new_nopar:Npn \zhcurrtime +\cs_new_nopar:Npn \__zhnum_time_aux:nn + { + \bool_if:NTF \l__zhnum_time_bool + { \__zhnum_time_aux:Nnnn \zhnum_int:n { } } + { \__zhnum_time_aux:Nnnn \int_to_arabic:n { \l__zhnum_arabic_sep_tl } } + } +\cs_new:Npn \__zhnum_time_aux:Nnnn #1#2#3#4 { - \zhnum_check_time:Nn \zhnum_int:n - { \int_div_truncate:nn \tex_time:D { 60 } } \c__zhnum_hour_tl - \zhnum_check_time:Nn \zhnum_int:n - { \int_mod:nn \tex_time:D { 60 } } \c__zhnum_minute_tl + #1 {#3} #2 \c__zhnum_hour_tl #2 + #1 {#4} #2 \c__zhnum_minute_tl } \cs_new:Npn \zhnum_digit_map:n #1 { \use:c { c__zhnum_ #1 _tl } } @@ -886,6 +925,7 @@ ganzhi-cyclic / false.code:n = { \cs_set_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_normal:nnn } , ganzhi-cyclic .default:n = { true } , + arabicsep .tl_set:N = \l__zhnum_arabic_sep_tl } \str_new:N \l__zhnum_encoding_str \msg_new:nnnn { zhnumber } { encoding-invalid } @@ -896,7 +936,7 @@ \keys_set:nn { zhnum / options } {#1} \tex_ignorespaces:D } -\keys_set:nn { zhnum / options } { style , time } +\keys_set:nn { zhnum / options } { style , time , arabicsep = { ~ } } \ProcessKeysOptions { zhnum / options } \str_if_empty:NT \l__zhnum_encoding_str { @@ -905,13 +945,13 @@ { \keys_set:nn { zhnum / options } { encoding = GBK } } } %% -%% This package consists of the file zhnumber.dtx, -%% and the derived files zhnumber.pdf, -%% zhnumber.sty, -%% zhnumber-utf8.cfg, -%% zhnumber-gbk.cfg, -%% zhnumber-big5.cfg, -%% zhnumber.ins and -%% README. +%% This package consists of the file zhnumber.dtx, +%% and the derived files zhnumber.pdf, +%% zhnumber.sty, +%% zhnumber-utf8.cfg, +%% zhnumber-gbk.cfg, +%% zhnumber-big5.cfg, +%% zhnumber.ins and +%% README.md. %% %% End of file `zhnumber.sty'. |