%%
%% This is file `dbshow.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% dbshow.dtx  (with options: `package')
%% 
%%     Copyright (C) 2022- by Changkai Li <lichangkai225@qq.com>
%%     --------------------------------------------------------------------------
%% 
%%     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 Changkai Li.
%% 
%%     This package consists of the file  dbshow.dtx,
%%                  and the derived files dbshow.pdf,
%%                                        dbshow.sty,
%%                                        dbshow.ins and
%%                                        README.md.
%%     --------------------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\GetIdInfo$Id: dbshow.dtx 1a507c4 2022-01-17 22:53:24 +0800 Changkai Li <lichangkai225@qq.com> $
  {Database to store and display data}
\ProvidesExplPackage{\ExplFileName}
  {\ExplFileDate}{1.5}{\ExplFileDescription}
\__kernel_dependency_version_check:nn { 2021-11-07 } { l3prop }
\__kernel_dependency_version_check:nn { 2021-05-17 } { l3str }
\__kernel_dependency_version_check:nn { 2021-05-10 } { l3clist }
\cs_generate_variant:Nn \msg_warning:nnnn      { nnnx }
\cs_generate_variant:Nn \keys_set:nn           { nv }
\cs_generate_variant:Nn \tl_put_right:Nn       { Nv }
\cs_generate_variant:Nn \clist_use:nn          { xx }
\cs_generate_variant:Nn \clist_use:nnnn        { xxxx }
\cs_generate_variant:Nn \clist_map_inline:nn   { Vn }
\cs_generate_variant:Nn \prop_get:NnN          { cVN }
\cs_generate_variant:Nn \regex_extract_all:nnN { nVN }
\cs_generate_variant:Nn \regex_split:nnN       { nVN }
\prg_generate_conditional_variant:Nnn \str_compare:nNn { VNV } { TF }
\prg_generate_conditional_variant:Nnn \int_compare:nNn { VNV } { TF }
\prg_generate_conditional_variant:Nnn \fp_compare:nNn  { VNV } { TF }
\prg_generate_conditional_variant:Nnn \regex_match:nn  { VV }  { TF }
\prg_generate_conditional_variant:Nnn \clist_if_in:Nn  { Nx }  { TF }
\prop_const_from_keyval:Nn \c__dbshow_default_value_prop {
  date  = \dbtoday,
  str   = ,
  tl    = ,
  clist = ,
  int   = 0,
  fp    = 0
}
\clist_const:Nn \__dbshow_type_clist { date, str, tl, clist, int, fp }
\int_gzero_new:N \g__dbshow_raw_filter_int
\msg_new:nnn { dbshow } { non-existent-database } {
  Database~'#1'~does~not~exist~\msg_line_context:.
}
\cs_new:Nn \__dbshow_check_database:n {
  \prop_if_exist:cF { g__dbshow_attr_type_prop_\tl_to_str:n {#1} }
    { \msg_fatal:nnn { dbshow } { non-existent-database } {#1} }
}
\msg_new:nnn { dbshow } { non-existent-attr } {
  Attribute~'#2'~of~database~'#1'~does~not~exist~\msg_line_context:.
}
\cs_new:Nn \__dbshow_check_attr:nn {
  \prop_if_in:cnF { g__dbshow_attr_type_prop_\tl_to_str:n {#1} } {#2}
    { \msg_fatal:nnnn { dbshow } { non-existent-attr } {#1} {#2} }
}
\cs_generate_variant:Nn \__dbshow_check_attr:nn { nV }
\msg_new:nnn { dbshow } { non-existent-style } {
  Style~'#1'~of~database~'#2'~does~not~exist~\msg_line_context:.
}
\cs_new:Nn \__dbshow_check_style:nn {
  \tl_if_exist:cF { g__dbshow_style_opts_tl_\tl_to_str:n {#1}_\tl_to_str:n {#2} }
    { \msg_fatal:nnnn { dbshow } { non-existent-style } {#1} {#2} }
}
\msg_new:nnn { dbshow } { non-existent-cond } {
  Conditional~'#2'~of~database~'#1'~does~not~exist~\msg_line_context:.
}
\cs_new:Nn \__dbshow_check_cond:nnn {
  \tl_if_exist:cF { g__dbshow_filter_attr_\tl_to_str:n {#1}_\tl_to_str:n {#2} }
    { \msg_fatal:nnnn { dbshow } { non-existent-cond } {#1} {#2} }
}
\msg_new:nnn { dbshow } { non-existent-filter } {
  Filter~'#2'~of~database~'#1'~does~not~exist~and~is~ignored~\msg_line_context:.
}
\cs_new:Nn \__dbshow_check_filter:nn {
  \seq_if_exist:cF
  { g__dbshow_filter_run_seq_\tl_to_str:n {#1}_\tl_to_str:n {#2} } {
    \str_if_eq:eeF {#2} { -none- } {
      \msg_warning:nnnx { dbshow } { non-existent-filter } {#1} {#2}
    }
  }
}
\cs_generate_variant:Nn \__dbshow_check_filter:nn { nv }
\msg_new:nnn { dbshow } { non-existent-type } {
  Type~'#1'~does~not~exist,~the~type~of~attribute~should~be~one~of~
  \{date,~str,~tl,~clist,~int,~fp\}~\msg_line_context:.
}
\cs_new:Nn \__dbshow_check_type:n {
  \clist_if_in:NnF \__dbshow_type_clist {#1}
    { \msg_fatal:nnn { dbshow } { non-existent-type } {#1} }
}
\msg_new:nnn { dbshow } { wrong-seperator } {
  option~'sep'~should~contain~#1~items~but~only~#2~items~was~given,~
  sep~=~\{#3\}~\msg_line_context:.
}
\cs_new:Nn \__dbshow_sep_fatal:nnn {
  \msg_fatal:nnnnn { dbshow } { wrong-seperator } {#1} {#2} {#3}
}
\cs_generate_variant:Nn \__dbshow_sep_fatal:nnn { xxx }
\msg_new:nnn { dbshow } { unsupported-sort-type } {
  unsupported~sort~type:~'#1'~\msg_line_context:.~The~type~should~be~one~of~
  \{str,~date,~int,~fp\}.
}
\cs_new:Npn \__dbshow_process_default_value:w
#1\__dbshow_sep#2\__dbshow_sep#3|#4\__dbshow_stop {
  \__dbshow_check_type:n {#3}
  \prop_gput:cxx { g__dbshow_attr_type_prop_#1 } {#2} {#3}
  \prop_gput:cno { g__dbshow_default_map_#1 } {#2} {#4}
}
\cs_new_protected:Nn \__dbshow_process_attr_type_prop:n {
  \prop_gclear_new:c { g__dbshow_default_map_#1 }
  \prop_map_inline:cn { g__dbshow_attr_type_prop_#1 } {
    \str_if_in:nnTF {##2} { | } {
      \__dbshow_process_default_value:w
        #1\__dbshow_sep##1\__dbshow_sep##2\__dbshow_stop
    } {
      \prop_get:NnN \c__dbshow_default_value_prop {##2} \l__dbshow_tmp_default
      \__dbshow_process_default_value:w
        #1\__dbshow_sep##1\__dbshow_sep##2|\l__dbshow_tmp_default\__dbshow_stop
    }
  }
}
\cs_new_protected:Nn \__dbshow_database_new:nn {
  \int_gzero_new:c { g__dbshow_counter_#1 }
  \prop_gset_from_keyval:cn { g__dbshow_attr_type_prop_#1 } {#2}
}
\cs_new_protected:Nn \__dbshow_database_new_append:nn {
  \int_gzero_new:c { g__dbshow_counter_#1 }
  \prop_if_exist:cF { g__dbshow_attr_type_prop_#1 }
    { \prop_new:c { g__dbshow_attr_type_prop_#1 } }
  \prop_gset_from_keyval:Nn \l_tmpa_prop {#2}
  \prop_concat:ccc { g__dbshow_attr_type_prop_#1 }
    { g__dbshow_attr_type_prop_#1 } { l_tmpa_prop }
}
\cs_new_protected:Nn \__dbshow_database_new_inherit:nnn {
  \__dbshow_check_database:n {#2}
  \str_if_eq:nnTF {#1} {#2} {
    \__dbshow_database_new_append:nn {#1} {#3}
  } {
    \int_gzero_new:c { g__dbshow_counter_#1 }
    \prop_gset_from_keyval:cn { g__dbshow_attr_type_prop_#1 } {#3}
    \prop_concat:ccc { g__dbshow_attr_type_prop_#1 }
      { g__dbshow_attr_type_prop_#2 } { g__dbshow_attr_type_prop_#1 }
  }
}
\NewDocumentCommand { \dbNewDatabase } { s o m m } {
  \IfNoValueTF {#2} {
    \IfBooleanTF {#1}
      { \__dbshow_database_new_append:nn {#3} {#4} }
      { \__dbshow_database_new:nn {#3} {#4} }
  } { \__dbshow_database_new_inherit:nnn {#3} {#2} {#4} }
  \__dbshow_database_new_append:nn {#3} { id=int }
  \__dbshow_process_attr_type_prop:n {#3}
  \__dbshow_set_database_keys:n {#3}
  \dbNewStyle{default}{#3}{}
}
\cs_new_protected:Nn \__dbshow_set_database_keys:n {
  \prop_map_inline:cn { g__dbshow_attr_type_prop_#1 } {
    \keys_define:nn { dbshow/database/#1 } {
      ##1 .code:n = \__dbshow_save_data:nnn {#1} {##1} {####1},
      ##1* .code:n = {
        \__dbshow_save_data:nnn {#1} {##1} { \exp_not:n {####1} },
      },
    }
  }
}
\cs_new:Nn \__dbshow_get_type:nn {
  \prop_item:cn { g__dbshow_attr_type_prop_#1 } {#2}
}
\cs_generate_variant:Nn \__dbshow_get_type:nn { nV }
\cs_new:Nn \__dbshow_get_counter:n {
  \int_use:c { g__dbshow_counter_#1 }
}
\cs_new:Nn \__dbshow_step_counter:n {
  \int_gincr:c { g__dbshow_counter_#1 }
}
\NewDocumentCommand { \dbclear } { m } {
  \int_gzero:c { g__dbshow_counter_#1 }
}
\cs_new:Nn \__dbshow_save_data:nnn {
  \__dbshow_check_attr:nn {#1} {#2}
  \str_case_e:nn { \__dbshow_get_type:nn {#1} {#2} } {
    { str }   { \str_clear_new:c }
    { tl }    { \tl_gclear_new:c }
    { clist } { \clist_gclear_new:c }
    { int }   { \int_gzero_new:c }
    { fp }    { \fp_gzero_new:c }
    { date }  { \__dbdate_gclear_new:x }
  } { g__dbshow_data_#1_#2_\__dbshow_get_counter:n {#1} }
  \str_case_e:nn { \__dbshow_get_type:nn {#1} {#2} } {
    { str }   { \str_gset:cn }
    { tl }    { \tl_gset:cn }
    { clist } { \clist_gset:cn }
    { int }   { \int_gset:cn }
    { fp }    { \fp_gset:cn }
    { date }  { \__dbdate_gset:xx }
  } { g__dbshow_data_#1_#2_\__dbshow_get_counter:n {#1} } {#3}
}
\cs_generate_variant:Nn \__dbshow_save_data:nnn { nnx }
\NewDocumentEnvironment { dbitem } { m +O{} } {
  \__dbshow_check_database:n {#1}
  \__dbshow_step_counter:n {#1}
  \cs_set:Nn \__dbshow_set_default:nn {
    \__dbshow_save_data:nnx {#1} {##1} {
      \prop_item:cn { g__dbshow_default_map_#1 } {##1}
    }
  }
  \prop_map_function:cN { g__dbshow_attr_type_prop_#1 } \__dbshow_set_default:nn
  \__dbshow_save_data:nnx {#1} { id } { \__dbshow_get_counter:n {#1} }
  \keys_set:nn { dbshow/database/#1 } {#2}
  \NewDocumentCommand { \dbsave } { s m +m } {
    \IfBooleanTF {##1} {
      \__dbshow_save_data:nnn {#1} {##2} { \exp_not:n {##3} }
    } {
      \__dbshow_save_data:nnn {#1} {##2} {##3}
    }
  }
} {}
\NewDocumentCommand { \dbitemkv } { m +m } {
  \begin{dbitem}{#1}[#2]
  \end{dbitem}
}
\cs_new:Nn \__dbshow_filter_int:NNNnn {
  \int_compare:nTF {#2} {#4} {#5}
}
\cs_generate_variant:Nn \__dbshow_filter_int:NNNnn { cccnn }
\cs_new:Nn \__dbshow_filter_fp:NNNnn {
  \int_compare:nTF {#2} {#4} {#5}
}
\cs_generate_variant:Nn \__dbshow_filter_fp:NNNnn { cccnn }
\cs_new_protected:Nn \__dbshow_filter_clist:NNNnn {
  \bool_if:NTF #1 {
    #4 \clist_map_inline:Vn #2
    { \clist_if_in:NnF #3 {##1} { #5 \clist_map_break: } }
  } {
    #5 \clist_map_inline:Vn #2
    { \clist_if_in:NnT #3 {##1} { #4 \clist_map_break: } }
  }
}
\cs_generate_variant:Nn \__dbshow_filter_clist:NNNnn { cccnn }
\cs_new_protected:Nn \__dbshow_filter_str:NNNnn {
  \bool_if:NT #1 {
    \tl_put_left:Nn #2 { \A }
    \tl_put_right:Nn #2 { \Z }
  }
  \regex_match:VVTF #2 #3 {#4} {#5}
}
\cs_generate_variant:Nn \__dbshow_filter_str:NNNnn { cccnn }
\cs_gset_eq:NN \__dbshow_filter_tl:NNNnn \__dbshow_filter_str:NNNnn
\cs_generate_variant:Nn \__dbshow_filter_tl:NNNnn { cccnn }
\cs_new_protected:Npn \__dbshow_parse_date_cond:NNw #1#2#3|#4\__dbshow_stop {
  \clist_set_eq:Nc #1 { g__review_points_#3 }
  \tl_set:Nn #2 {#4}
}
\cs_new_protected:Nn \__dbshow_filter_date:NNNnn {
  \bool_if:NTF #1 {
    \int_zero_new:N \l__dbshow_filter_diff_int
    \exp_last_unbraced:NNNV \__dbshow_parse_date_cond:NNw
      \l__dbshow_filter_tmp_clist \l__dbshow_filter_tmp_tl {#2} \__dbshow_stop
    \__dbdate_clear_new:n { tmp_day1 }
    \__dbdate_clear_new:n { tmp_day2 }
    \__dbdate_set:xx { tmp_day1 } { \l__dbshow_filter_tmp_tl }
    \__dbdate_set:xx { tmp_day2 } {#3}
    \__dbdate_sub:nnN { tmp_day1 } { tmp_day2 } \l__dbshow_filter_diff_int
    #5
    \clist_map_inline:Nn \l__dbshow_filter_tmp_clist {
      \int_compare:nNnT { \l__dbshow_filter_diff_int } = {##1}
        { #4 \clist_map_break: }
    }
  } {
    \int_zero_new:N \l__dbshow_filter_tmpa_int
    \int_zero_new:N \l__dbshow_filter_tmpb_int
    \tl_set:Nx \l__dbshow_expr_tl {#2}
    \regex_extract_all:nVN { \d{4}/\d+/\d+ }
      \l__dbshow_expr_tl \l__dbshow_filter_date_seq
    \regex_split:nVN { \d{4}/\d+/\d+ }
      \l__dbshow_expr_tl \l__dbshow_filter_other_seq
    \tl_clear:N \l__dbshow_expr_tl
    \int_set:Nn \l__dbshow_filter_tmpa_int
      { \seq_count:N \l__dbshow_filter_date_seq }
    \int_step_inline:nn { \l__dbshow_filter_tmpa_int } {
      \tl_put_right:Nx \l__dbshow_expr_tl
        { \seq_item:Nn \l__dbshow_filter_other_seq {##1} }
      \__dbdate_clear_new:n { date-tmp }
      \__dbdate_set:xx { date-tmp }
        { \seq_item:Nn \l__dbshow_filter_date_seq {##1} }
      \__dbdate_to_int:nN { date-tmp } \l__dbshow_filter_tmpb_int
      \tl_put_right:Nx \l__dbshow_expr_tl
        { \int_use:N \l__dbshow_filter_tmpb_int }
    }
    \tl_put_right:Nx \l__dbshow_expr_tl {
      \seq_item:Nn \l__dbshow_filter_other_seq
        { \l__dbshow_filter_tmpa_int + 1 }
    }
    \int_compare:nTF { \l__dbshow_expr_tl } {#4} {#5}
  }
}
\cs_generate_variant:Nn \__dbshow_filter_date:NNNnn { cccnn }
\cs_new_protected:Nn \__dbshow_filter:nnn {
  \tl_set_eq:Nc \l__dbshow_attr_tl { g__dbshow_filter_attr_tl_#1_#2 }
  \cs_set_eq:Nc \dbval { g__dbshow_data_#1_\l__dbshow_attr_tl _#3 }
  \tl_set:Nx \l__dbshow_type_tl { \__dbshow_get_type:nV {#1} \l__dbshow_attr_tl }
  \use:c
    { __dbshow_filter_\l__dbshow_type_tl :cccnn }
    { g__dbshow_cond_star_bool_#1_#2 }
    { g__dbshow_filter_expr_tl_#1_#2 }
    { dbval }
    { \bool_gset_true:c  { g__dbshow_filter_bool_#1_#2 } }
    { \bool_gset_false:c { g__dbshow_filter_bool_#1_#2 } }
}
\cs_new_protected:Nn \__dbshow_new_conditional:nnnnn {
  \__dbshow_check_database:n {#1}
  \__dbshow_check_attr:nn {#1} {#3}
  \tl_gset:cn { g__dbshow_filter_attr_tl_#1_#2 } {#3}
  \tl_gset:cn { g__dbshow_filter_expr_tl_#1_#2 } {#4}
  \bool_if_exist:cF { g__dbshow_filter_bool_#1_#2 }
    { \bool_new:c { g__dbshow_filter_bool_#1_#2 } }
  \bool_if_exist:cF { g__dbshow_cond_star_bool_#1_#2 }
    { \bool_new:c { g__dbshow_cond_star_bool_#1_#2 } }
  \IfBooleanTF {#5}
    { \bool_gset_true:c { g__dbshow_cond_star_bool_#1_#2 } }
    { \bool_gset_false:c { g__dbshow_cond_star_bool_#1_#2 } }
  \cs_gset:cn { g__dbshow_filter_hook_#1_#2:n } {
    \__dbshow_filter:nnn {#1} {#2} {##1}
  }
  \bool_if_exist:cF { g__dbshow_cond_exist_bool_#1_#2 }
    { \bool_set_false:c { g__dbshow_cond_exist_bool_#1_#2 } }
  \bool_if:cF { g__dbshow_cond_exist_bool_#1_#2 }
    { \seq_gput_right:cn { g__dbshow_cond_seq_#1 } {#2} }
}
\cs_new_protected:Nn \__dbshow_combine_conditional:nnn {
  \tl_gset_eq:cN { g__dbshow_filter_bool_tl_#1_#2 } \c_true_bool
  \seq_gclear_new:c { g__dbshow_filter_run_seq_#1_#2 }
  \regex_extract_all:nnN { [^!=&<>()\ ]+ } {#3} \l__dbshow_cond_seq
  \seq_map_inline:Nn \l__dbshow_cond_seq {
    \seq_if_in:cnT { g__dbshow_cond_seq_#1 } {##1} {
      \seq_if_in:cnF { g__dbshow_filter_run_seq_#1_#2 }
        { g__dbshow_filter_hook_#1_##1:n }
      {
        \seq_gput_right:cn { g__dbshow_filter_run_seq_#1_#2 }
          { g__dbshow_filter_hook_#1_##1:n }
      }
    }
  }
  \tl_set:Nn \l__dbshow_cond_expr_tl {#3}
  \regex_replace_all:nnN
    { (\w|-|\d|\_)+ }
    { \c{ g__dbshow_filter_bool_#1_\0 } }
    \l__dbshow_cond_expr_tl
  \tl_gset_eq:cN
    { g__dbshow_filter_bool_tl_#1_#2 } \l__dbshow_cond_expr_tl
}
\cs_generate_variant:Nn \__dbshow_combine_conditional:nnn { nVn }
\NewDocumentEnvironment { dbFilters } { s m } {
  \seq_if_exist:cF { g__dbshow_cond_seq_#2 }
    { \seq_new:c { g__dbshow_cond_seq_#2 } }
  \DeclareDocumentCommand { \dbNewConditional } { s m m m O{} } {
    \__dbshow_new_conditional:nnnnn {#2} {##2} {##3} {##4} {##1}
    \IfValueT {#1} {
      \dbCombCond{##2}{##2}[##5]
    }
  }
  \DeclareDocumentCommand { \dbCombineConditionals } { m m O{} } {
    \tl_gset:cn { g__dbshow_filter_info_tl_#2_##1 } {##3}
    \__dbshow_combine_conditional:nnn {#2} {##1} {##2}
  }
  \cs_set_eq:NN \dbNewCond  \dbNewConditional
  \cs_set_eq:NN \dbCombCond \dbCombineConditionals
} {}
\DeclareDocumentCommand { \dbNewRawFilter } { s m m m m O{} } {
  \seq_if_exist:cF { g__dbshow_cond_seq_#3 }
    { \seq_new:c { g__dbshow_cond_seq_#3 } }
  \__dbshow_new_conditional:nnnnn {#3} {#2} {#4} {#5} {#1}
  \tl_gset:cn { g__dbshow_filter_info_tl_#3_#2 } {#6}
  \__dbshow_combine_conditional:nnn {#3} {#2} {#2}
}
\NewDocumentCommand { \dbNewReviewPoints } { m m } {
  \clist_set:cn { g__review_points_#1 } {#2}
}
\cs_gset_eq:NN \dbIntAbs         \int_abs:n
\cs_gset_eq:NN \dbIntSign        \int_sign:n
\cs_gset_eq:NN \dbIntDivRound    \int_div_round:nn
\cs_gset_eq:NN \dbIntDivTruncate \int_div_truncate:nn
\cs_gset_eq:NN \dbIntMax         \int_max:nn
\cs_gset_eq:NN \dbIntMin         \int_min:nn
\cs_gset_eq:NN \dbIntMod         \int_mod:nn
\cs_gset_eq:NN \dbFpSign         \fp_sign:n
\cs_new_protected:Nn \__dbshow_new_attr_style:nnn {
  \__dbshow_check_attr:nn {#2} {#3}
  \keys_define:nn { dbshow/style/#1/#3 } {
    before-code      .tl_gset:c    = {
      g__dbshow_style_attr_before_tl_#1_#2_#3
    },
    before-code      .initial:n    = ,
    after-code       .tl_gset:c    = {
      g__dbshow_style_attr_after_tl_#1_#2_#3
    },
    after-code       .initial:n    = ,
    code             .code:n       = {
      \bool_gset_false:c { g__dbshow_style_attr_exp_bool_#1_#2_#3 }
      \cs_gset:cn { __dbshow_style_attr_code_#1_#2_#3:n } {##1}
    },
    code             .initial:n    = {##1},
    code*            .code:n       = {
      \bool_gset_true:c  { g__dbshow_style_attr_exp_bool_#1_#2_#3 }
      \cs_gset:cn { __dbshow_style_attr_code_#1_#2_#3:n } {##1}
    },
    sep              .clist_gset:c = {
      g__dbshow_style_attr_sep_#1_#2_#3
    },
    item-before-code .tl_gset:c    = {
      g__dbshow_style_attr_item_before_tl_#1_#2_#3
    },
    item-before-code .initial:n    = ,
    item-after-code  .tl_gset:c    = {
      g__dbshow_style_attr_item_after_tl_#1_#2_#3
    },
    item-after-code  .initial:n    = ,
    item-code        .code:n       = {
      \bool_gset_false:c { g__dbshow_style_clist_item_exp_bool_#1_#2_#3 }
      \cs_gset:cn { __dbshow_style_clist_item_code_#1_#2_#3:n } {##1}
    },
    item-code        .initial:n    = {##1},
    item-code*       .code:n       = {
      \bool_gset_true:c  { g__dbshow_style_clist_item_exp_bool_#1_#2_#3 }
      \cs_gset:cn { __dbshow_style_clist_item_code_#1_#2_#3:n } {##1}
    },
    zfill            .bool_gset:c  = {
      g__dbshow_style_date_zfill_bool_#1_#2_#3
    },
    zfill            .initial:n    = true,
    zfill            .default:n    = true,
    format-code      .code:n       = {
      \cs_gset:cn { __dbshow_style_date_format_code_#1_#2_#3:nnn } {##1}
      \cs_generate_variant:cn
        { __dbshow_style_date_format_code_#1_#2_#3:nnn } { xxx }
    },
  }
  \str_case_e:nn { \__dbshow_get_type:nn {#2} {#3} } {
    { clist }
    { \keys_set:nn { dbshow/style/#1/#3 } { sep = { { ,~ } } } }
    { date }
    { \keys_set:nn { dbshow/style/#1/#3 } { sep = { { /  } } } }
  }
}
\cs_new_protected:Nn \__dbshow_new_database_style:nn {
  \__dbshow_check_database:n {#2}
  \keys_define:nn { dbshow/style/#1 } {
    raw-filter         .code:n       = {
      \int_gincr:N  \g__dbshow_raw_filter_int
      \str_set:Nx \l__dbshow_raw_filter_str
        { -raw\int_use:N \g__dbshow_raw_filter_int - }
      \tl_gset:cV { g__dbshow_filter_#1_#2 } \l__dbshow_raw_filter_str
      \__dbshow_combine_conditional:nVn {#2}  \l__dbshow_raw_filter_str {##1}
    },
    filter           .tl_gset:c    = { g__dbshow_filter_#1_#2 },
    filter           .initial:n    = -none-,
    sort             .clist_gset:c = { g__dbshow_sort_clist_#1_#2 },
    before-code      .tl_gset:c    = { g__dbshow_style_before_tl_#1_#2 },
    before-code      .initial:n    = ,
    after-code       .tl_gset:c    = { g__dbshow_style_after_tl_#1_#2 },
    after-code       .initial:n    = ,
    item-before-code .tl_gset:c    = { g__dbshow_style_item_before_tl_#1_#2 },
    item-before-code .initial:n    = ,
    item-after-code  .tl_gset:c    = { g__dbshow_style_item_after_tl_#1_#2 },
    item-after-code  .initial:n    = ,
    item-code        .code:n       = {
      \bool_gset_false:c { g__dbshow_style_item_exp_bool_#1_#2 }
      \tl_gset:cn { g__dbshow_style_item_tl_#1_#2 } {##1}
    },
    item-code        .initial:n    = ,
    item-code*       .code:n       = {
      \bool_gset_true:c { g__dbshow_style_item_exp_bool_#1_#2 }
      \tl_gset:cn { g__dbshow_style_item_tl_#1_#2 } {##1}
    },
  }
  \prop_map_inline:cn { g__dbshow_attr_type_prop_#2 }
    { \__dbshow_new_attr_style:nnn {#1} {#2} {##1} }
}
\NewDocumentCommand { \dbNewStyle } { o m m +m } {
  \__dbshow_check_database:n {#3}
  \tl_gset:cn { g__dbshow_style_opts_tl_#2_#3 } { #4, }
  \IfValueT {#1} {
    \tl_clear_new:N \l__dbshow_style_tmp_tl
    \clist_map_inline:nn {#1} {
      \__dbshow_check_style:nn {##1} {#3}
      \tl_if_exist:cT { g__dbshow_style_opts_tl_##1_#3 } {
        \tl_concat:ccc { l__dbshow_style_tmp_tl }
          { l__dbshow_style_tmp_tl } { g__dbshow_style_opts_tl_##1_#3 }
      }
    }
    \tl_gconcat:ccc { g__dbshow_style_opts_tl_#2_#3 }
      { l__dbshow_style_tmp_tl } { g__dbshow_style_opts_tl_#2_#3 }
  }
  \__dbshow_new_database_style:nn {#2} {#3}
  \keys_set:nv { dbshow/style/#2 } { g__dbshow_style_opts_tl_#2_#3 }
}
\cs_new_protected:Npn \__dbshow_sort_parse_star:NNNw #1#2#3#4* {
  \tl_set:Nn #1 { > }
  \tl_set:Nn #2 { < }
  \tl_set:Nn #3 {#4}
}
\cs_new_protected:Nn \__dbshow_sort:nNn {
  \int_zero_new:N \l__dbshow_sort_len_int
  \int_zero_new:N \l__dbshow_sort_tmp_int
  \int_set:Nn \l__dbshow_sort_len_int
    { \clist_count:c { g__dbshow_sort_clist_#3_#1 } }
  \clist_sort:Nn #2 {
    \int_zero:N \l__dbshow_sort_tmp_int
    \cs_set:Nn \__dbshow_sort_single: {
      \int_incr:N \l__dbshow_sort_tmp_int
      \str_set:Nx \l__dbshow_sort_attr_str {
        \clist_item:cn
          { g__dbshow_sort_clist_#3_#1 }
          { \l__dbshow_sort_tmp_int }
      }
      \str_if_in:NnTF \l__dbshow_sort_attr_str { * } {
        \exp_after:wN \__dbshow_sort_parse_star:NNNw
          \exp_after:wN \l__dbshow_sort_same_op_tl
          \exp_after:wN \l__dbshow_sort_swap_op_tl
          \exp_after:wN \l__dbshow_sort_attr_str
          \l__dbshow_sort_attr_str
      } {
        \tl_set:Nn \l__dbshow_sort_same_op_tl { < }
        \tl_set:Nn \l__dbshow_sort_swap_op_tl { > }
      }
      \__dbshow_check_attr:nV {#1} \l__dbshow_sort_attr_str
      \tl_set:Nx \l__dbshow_sort_type_tl
        { \__dbshow_get_type:nV {#1} \l__dbshow_sort_attr_str }
      \clist_if_in:nVF
      { str, int, date, fp } { \l__dbshow_sort_type_tl } {
        \msg_fatal:nnx { dbshow } { unsupported-sort-type }
          { \l__dbshow_sort_type_tl }
      }
      \str_if_eq:eeT { \l__dbshow_sort_type_tl } { date }
        { \tl_set:Nn \l__dbshow_sort_type_tl { str } }
      \cs_set_eq:Nc \l__dbshow_sort_tmpa_tl
        { g__dbshow_data_#1_\l__dbshow_sort_attr_str _##1 }
      \cs_set_eq:Nc \l__dbshow_sort_tmpb_tl
        { g__dbshow_data_#1_\l__dbshow_sort_attr_str _##2 }
      \cs_set_eq:Nc \__dbshow_compare
        { \l__dbshow_sort_type_tl _compare:VNVTF }
      \__dbshow_compare \l__dbshow_sort_tmpa_tl
        \l__dbshow_sort_same_op_tl \l__dbshow_sort_tmpb_tl
        { \sort_return_same: }
      {
        \__dbshow_compare \l__dbshow_sort_tmpa_tl
          \l__dbshow_sort_swap_op_tl \l__dbshow_sort_tmpb_tl
          { \sort_return_swapped: }
        {
          \int_compare:nTF
            { \l__dbshow_sort_len_int = \l__dbshow_sort_tmp_int }
            { \sort_return_same: }
            { \__dbshow_sort_single: }
        }
      }
    }
    \__dbshow_sort_single:
  }
}
\cs_new:Nn \__dbshow_clist_wrapper:NNNNn {
  \bool_if:NTF #4
    { \exp_not:n { { #1\exp_args:Nx#3{#5}#2 }, } }
    { \exp_not:n { { #1#3{#5}#2 }, } }
}
\cs_new:Nn \__dbshow_clist_use:NNNNNN {
  \int_case:nnF { \clist_count:N #2 } {
    { 1 } {
      \clist_use:xx
        { \clist_map_tokens:Nn #1 { \__dbshow_clist_wrapper:NNNNn #3#4#5#6 } }
        { \clist_item:Nn #2 { 1 } }
    }
    { 3 } {
      \clist_use:xxxx
        { \clist_map_tokens:Nn #1 { \__dbshow_clist_wrapper:NNNNn #3#4#5#6 } }
        { \clist_item:Nn #2 { 1 } }
        { \clist_item:Nn #2 { 2 } }
        { \clist_item:Nn #2 { 3 } }
    }
  } {
    \__dbshow_sep_fatal:xxx
      { 1~or~3 }
      { \clist_count:N #2 }
      { \clist_use:Nn #2 { ,~ } }
  }
}
\cs_generate_variant:Nn \__dbshow_clist_use:NNNNNN { cccccc }
\cs_new:Nn \__dbshow_date_use:nNN {
  \int_case:nnF { \clist_count:N #2 } {
    { 1 } {
      \bool_if:NTF {#3}
        { \__dbdate_use_zfill:nf }
        { \__dbdate_use:nf }
        {#1}
        { \clist_item:Nn #2 { 1 } }
    }
    { 4 } {
      \bool_if:NTF {#3}
        { \__dbdate_use_zfill:nffff }
        { \__dbdate_use:nffff }
        {#1}
        { \clist_item:Nn #2 { 1 } }
        { \clist_item:Nn #2 { 2 } }
        { \clist_item:Nn #2 { 3 } }
        { \clist_item:Nn #2 { 4 } }
    }
  } {
    \__dbshow_sep_fatal:xxx
      { 1~or~4 }
      { \clist_count:N #2 }
      { \clist_use:Nn #2 { ,~ } }
  }
}
\cs_generate_variant:Nn \__dbshow_date_use:nNN { ncc }
\cs_new:Nn \__dbshow_use_data:nnnn {
  \bool_if:cTF { g__dbshow_style_attr_exp_bool_#4_#1_#2 } {
    \protected@edef\@dbshow@tmp{\__dbshow_use_data_raw:nnnn {#1} {#2} {#3} {#4}}
    \exp_args:Nno
    \use:c { __dbshow_style_attr_code_#4_#1_#2:n } { \@dbshow@tmp }
  } {
    \use:c { __dbshow_style_attr_code_#4_#1_#2:n }
    { \__dbshow_use_data_raw:nnnn {#1} {#2} {#3} {#4} }
  }
}
\cs_new:Nn \__dbshow_use_data_raw:nnnn {
  \str_case_e:nn
  { \prop_item:cn { g__dbshow_attr_type_prop_#1 } {#2} } {
    { str }   { \str_use:c { g__dbshow_data_#1_#2_#3 } }
    { tl }    { \tl_use:c  { g__dbshow_data_#1_#2_#3 } }
    { int }   { \int_use:c { g__dbshow_data_#1_#2_#3 } }
    { fp }    { \fp_use:c  { g__dbshow_data_#1_#2_#3 } }
    { clist } {
      \__dbshow_clist_use:cccccc { g__dbshow_data_#1_#2_#3 }
        { g__dbshow_style_attr_sep_#4_#1_#2 }
        { g__dbshow_style_attr_item_before_tl_#4_#1_#2 }
        { g__dbshow_style_attr_item_after_ tl_#4_#1_#2 }
        {   __dbshow_style_clist_item_code_    #4_#1_#2:n }
        { g__dbshow_style_clist_item_exp_bool_#4_#1_#2 }
    }
    { date }  {
      \cs_if_exist_use:cTF { __dbshow_style_date_format_code_#4_#1_#2:xxx } {
        { \__dbdate_get_year:n  { g__dbshow_data_#1_#2_#3 } }
        { \__dbdate_get_month:n { g__dbshow_data_#1_#2_#3 } }
        { \__dbdate_get_day:n   { g__dbshow_data_#1_#2_#3 } }
      } {
        \__dbshow_date_use:ncc { g__dbshow_data_#1_#2_#3 }
          { g__dbshow_style_attr_sep_#4_#1_#2 }
          { g__dbshow_style_date_zfill_bool_#4_#1_#2 }
      }
    }
  }
}
\cs_new_protected:Nn \__dbshow_show_set_macro:nn {
  \tl_set:Nn    \dbDatabase   {#1}
  \tl_set:Nn    \dbFilterName {#2}
  \tl_set_eq:Nc \dbFilterInfo { g__dbshow_filter_info_tl_#1_#2 }
}
\cs_new_protected:Nn \__dbshow_show_filter:nnN {
  \int_step_inline:nn { \__dbshow_get_counter:n {#1} } {
    \seq_if_exist:cTF { g__dbshow_filter_run_seq_#1_#2 } {
      \seq_map_inline:cn { g__dbshow_filter_run_seq_#1_#2 } {
        \use:c {####1} {##1}
      }
      \exp_args:Nv
      \bool_if:nT { g__dbshow_filter_bool_tl_#1_#2 }
        { \clist_put_right:Nn #3 {##1} }
    } { \clist_put_right:Nn #3 {##1} }
  }
}
\cs_new_protected:Nn \__dbshow_show_set_counter:N {
  \tl_set:Nx \dbalph   { \int_to_alph:n   {#1} }
  \tl_set:Nx \dbAlph   { \int_to_Alph:n   {#1} }
  \tl_set:Nx \dbarabic { \int_to_arabic:n {#1} }
  \tl_set:Nx \dbRoman  { \int_to_Roman:n  {#1} }
  \tl_set:Nx \dbroman  { \int_to_roman:n  {#1} }
}
\cs_new_protected:Nn \__dbshow_show_set_if_last:NN {
  \prg_set_conditional:Nnn \__dbshow_show_if_last: { T, F, TF } {
    \int_compare:nNnTF {#1} = {#2}
      { \prg_return_true: }
      { \prg_return_false: }
  }
  \cs_set_eq:NN \dbIfLastT  \__dbshow_show_if_last:T
  \cs_set_eq:NN \dbIfLastF  \__dbshow_show_if_last:F
  \cs_set_eq:NN \dbIfLastTF \__dbshow_show_if_last:TF
}
\cs_new_protected:Nn \__dbshow_show_item:nnN {
  \int_zero_new:N \l__dbshow_show_int
  \int_zero_new:N \l__dbshow_show_count_int
  \int_set:Nn \l__dbshow_show_count_int { \clist_count:N #3 }
  \tl_clear_new:N \l__dbshow_item_tl
  \clist_map_inline:Nn #3 {
    \int_incr:N \l__dbshow_show_int
    \__dbshow_show_set_if_last:NN \l__dbshow_show_int \l__dbshow_show_count_int
    \__dbshow_show_set_counter:N  \l__dbshow_show_int
    \tl_set:Nn \dbIndex {##1}
    \cs_set:Npn \dbuse ####1 {
      \__dbshow_check_attr:nn {#2} {####1}
      \tl_use:c { g__dbshow_style_attr_before_tl_#1_#2_####1 }
      \__dbshow_use_data:nnnn {#2} {####1} {##1} {#1}
      \tl_use:c { g__dbshow_style_attr_after_ tl_#1_#2_####1 }
    }
    \bool_if:cTF { g__dbshow_style_item_exp_bool_#1_#2 } {
      \protected@edef\@dbshow@tmp{\tl_use:c { g__dbshow_style_item_before_tl_#1_#2 }}
      \tl_put_right:No \l__dbshow_item_tl { \@dbshow@tmp }
      \protected@edef\@dbshow@tmp{\tl_use:c { g__dbshow_style_item_       tl_#1_#2 }}
      \tl_put_right:No \l__dbshow_item_tl { \@dbshow@tmp }
      \protected@edef\@dbshow@tmp{\tl_use:c { g__dbshow_style_item_after_ tl_#1_#2 }}
    } {
      \tl_use:c { g__dbshow_style_item_before_tl_#1_#2 }
      \tl_use:c { g__dbshow_style_item_       tl_#1_#2 }
      \tl_use:c { g__dbshow_style_item_after_ tl_#1_#2 }
    }
  }
  \l__dbshow_item_tl
}
\cs_new_protected:Nn \__dbshow_show_set_cond:N {
  \prg_set_conditional:Nnn \__dbshow_if_empty: { T, F, TF } {
    \clist_if_empty:NTF #1
      { \prg_return_true: }
      { \prg_return_false: }
  }
  \cs_set_eq:NN \dbIfEmptyT  \__dbshow_if_empty:T
  \cs_set_eq:NN \dbIfEmptyF  \__dbshow_if_empty:F
  \cs_set_eq:NN \dbIfEmptyTF \__dbshow_if_empty:TF
}
\cs_new_protected:Nn \__dbshow_show:nnn {
  \__dbshow_show_set_macro:nn {#2} {#3}
  \clist_clear_new:N \l__dbshow_show_index_clist
  \__dbshow_show_filter:nnN {#2} {#3} \l__dbshow_show_index_clist
  \clist_if_empty:cF { g__dbshow_sort_clist_#1_#2 }
    { \__dbshow_sort:nNn {#2} \l__dbshow_show_index_clist {#1} }
  \__dbshow_show_set_cond:N \l__dbshow_show_index_clist
  \tl_use:c { g__dbshow_style_before_tl_#1_#2 }
  \__dbshow_show_item:nnN {#1} {#2} \l__dbshow_show_index_clist
  \tl_use:c { g__dbshow_style_after_tl_#1_#2 }
}
\cs_generate_variant:Nn \__dbshow_show:nnn { nnv }
\NewDocumentCommand { \dbshow } { m m } {
  \__dbshow_check_database:n {#2}
  \__dbshow_check_style:nn   {#1} {#2}
  \__dbshow_check_filter:nv  {#2} { g__dbshow_filter_#1_#2 }
  \__dbshow_show:nnv {#1}    {#2} { g__dbshow_filter_#1_#2 }
}
\msg_new:nnn { dbshow } { wrong-date-sep } {
  can~not~parse~the~date~'#1'~with~the~global~date~separator~'#2'~
  \msg_line_context:.~Please~set~the~correct~date~separator~with~
  \dbdatesep.
}
\cs_new:Nn \__dbdate_check_date_sep:nn {
  \int_zero_new:N \l__dbdate_sep_int
  \tl_map_inline:nn {#1} {
    \tl_if_eq:nnT {#2} {##1} { \int_incr:N \l__dbdate_sep_int }
    \int_compare:nNnT { \l__dbdate_sep_int } > { 2 } { \tl_map_break: }
  }
  \int_compare:nNnF { \l__dbdate_sep_int } = { 2 }
    { \msg_fatal:nnnn { dbshow } { wrong-date-sep } {#1} {#2} }
}
\cs_generate_variant:Nn \__dbdate_check_date_sep:nn { nV }
\prg_new_conditional:Nnn \__dbdate_if_leap:n { T, F, TF, p } {
  \bool_if:nTF {
    \int_compare_p:nNn { \int_mod:nn {#1} { 400 } } = { 0 } ||
    (!\int_compare_p:nNn { \int_mod:nn {#1} { 100 } } = { 0 } &&
      \int_compare_p:nNn { \int_mod:nn {#1} { 4 } } = { 0 })
  } { \prg_return_true: } { \prg_return_false: }
}
\clist_const:Nn \c__dbdate_month_clist
  { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
\cs_new_protected:Nn \__dbdate_to_int:nnnN {
  \int_zero_new:N \l__dbdate_ans_int
  \int_zero_new:N \l__dbdate_tmpa_int
  \int_zero_new:N \l__dbdate_tmpb_int
  \int_set:Nn \l__dbdate_ans_int { #3 - 1 }
  \int_step_inline:nn { #2 - 1 } {
    \int_add:Nn \l__dbdate_ans_int {
      \clist_item:Nn \c__dbdate_month_clist {##1}
    }
    \bool_if:nT {
      \int_compare_p:nNn {##1} = { 2 } &&
      \__dbdate_if_leap_p:n {#1}
    } { \int_incr:N \l__dbdate_ans_int }
  }
  \int_add:Nn \l__dbdate_ans_int { 365 * (#1 - 1971) }
  \int_add:Nn \l__dbdate_ans_int {
    \int_div_truncate:nn { #1 - 1 } { 4 } -
    \int_div_truncate:nn { 1971 } { 4 }
  }
  \int_sub:Nn \l__dbdate_ans_int {
    \int_div_truncate:nn { #1 - 1 } { 100 } -
    \int_div_truncate:nn { 1971 } { 100 }
  }
  \int_add:Nn \l__dbdate_ans_int {
    \int_div_truncate:nn { #1 - 1 } { 400 } -
    \int_div_truncate:nn { 1971 } { 400 }
  }
  \int_set_eq:NN #4 \l__dbdate_ans_int
}
\cs_new_protected:Nn \__dbdate_to_int:NNNN {
  \__dbdate_to_int:nnnN {#1} {#2} {#3} #4
}
\cs_generate_variant:Nn \__dbdate_to_int:NNNN { cccN }
\cs_new:Nn \__dbdate_to_int:nN {
  \__dbdate_to_int:cccN
    { __dbdate_year_#1 }
    { __dbdate_month_#1 }
    { __dbdate_day_#1 }
    #2
}
\cs_new_protected:Nn \__dbdate_set_val:n {
  \tl_set:cx {#1} { \__dbdate_use_zfill:nn {#1} { \g__dbdate_sep_tl } }
}
\cs_new_protected:Nn \__dbdate_gset_val:n {
  \tl_gset:cx {#1} { \__dbdate_use_zfill:nn {#1} { \g__dbdate_sep_tl } }
}
\cs_new_protected:Nn \__dbdate_init:n {
  \__dbdate_set:nnnn {#1} { 1971 } { 1 } { 1 }
  \__dbdate_set_val:n {#1}
}
\cs_new_protected:Nn \__dbdate_ginit:n {
  \__dbdate_gset:nnnn {#1} { 1971 } { 1 } { 1 }
  \__dbdate_gset_val:n {#1}
}
\cs_new_protected:Nn \__dbdate_new:n {
  \int_new:c { __dbdate_year_#1 }
  \int_new:c { __dbdate_month_#1 }
  \int_new:c { __dbdate_day_#1 }
  \__dbdate_ginit:n {#1}
}
\cs_generate_variant:Nn \__dbdate_new:n { x }
\cs_new_protected:Nn \__dbdate_clear_new:n {
  \int_zero_new:c { __dbdate_year_#1 }
  \int_zero_new:c { __dbdate_month_#1 }
  \int_zero_new:c { __dbdate_day_#1 }
  \__dbdate_init:n {#1}
}
\cs_generate_variant:Nn \__dbdate_clear_new:n { x }
\cs_new_protected:Nn \__dbdate_gclear_new:n {
  \int_gzero_new:c { __dbdate_year_#1 }
  \int_gzero_new:c { __dbdate_month_#1 }
  \int_gzero_new:c { __dbdate_day_#1 }
  \__dbdate_ginit:n {#1}
}
\cs_generate_variant:Nn \__dbdate_gclear_new:n { x }
\cs_new:Nn \__dbdate_get_year:n {
  \int_use:c { __dbdate_year_#1 }
}
\cs_new:Nn \__dbdate_get_month:n {
  \int_use:c { __dbdate_month_#1 }
}
\cs_new:Nn \__dbdate_get_day:n {
  \int_use:c { __dbdate_day_#1 }
}
\cs_generate_variant:Nn \__dbdate_get_year:n  { x }
\cs_generate_variant:Nn \__dbdate_get_month:n { x }
\cs_generate_variant:Nn \__dbdate_get_day:n   { x }
\cs_new_protected:Nn \__dbdate_set:nnnn {
  \int_set:cn { __dbdate_year_#1 }  {#2}
  \int_set:cn { __dbdate_month_#1 } {#3}
  \int_set:cn { __dbdate_day_#1 }   {#4}
  \__dbdate_set_val:n {#1}
}
\cs_new_protected:Nn \__dbdate_gset:nnnn {
  \int_gset:cn { __dbdate_year_#1 }  {#2}
  \int_gset:cn { __dbdate_month_#1 } {#3}
  \int_gset:cn { __dbdate_day_#1 }   {#4}
  \__dbdate_gset_val:n {#1}
}
\cs_new_protected:Nn \__dbdate_set_sep:n {
  \tl_gset:Nn \g__dbdate_sep_tl { #1 }
  \cs_gset_protected:Npn \__dbdate_set:w ##1\__dbdate_sep##2#1##3#1##4\__dbdate_stop {
    \__dbdate_clear_new:n {##1}
    \__dbdate_set:nnnn {##1} {##2} {##3} {##4}
  }
  \cs_gset_protected:Npn \__dbdate_gset:w ##1\__dbdate_sep##2#1##3#1##4\__dbdate_stop {
    \__dbdate_gclear_new:n {##1}
    \__dbdate_gset:nnnn {##1} {##2} {##3} {##4}
  }
}
\cs_gset_eq:NN \dbdatesep \__dbdate_set_sep:n
\dbdatesep{/}
\cs_new_protected:Nn \__dbdate_set:nn {
  \__dbdate_check_date_sep:nV {#2} \g__dbdate_sep_tl
  \__dbdate_set:w #1\__dbdate_sep#2\__dbdate_stop
}
\cs_generate_variant:Nn \__dbdate_set:nn { xx }
\cs_new_protected:Nn \__dbdate_gset:nn {
  \__dbdate_check_date_sep:nV {#2} \g__dbdate_sep_tl
  \__dbdate_gset:w #1\__dbdate_sep#2\__dbdate_stop
}
\cs_generate_variant:Nn \__dbdate_gset:nn { xx }
\cs_new_protected:Nn \__dbdate_sub:nnN {
  \int_zero_new:N \l__dbdate_sub_tmpa_int
  \int_zero_new:N \l__dbdate_sub_tmpb_int
  \__dbdate_to_int:nN {#1} \l__dbdate_sub_tmpa_int
  \__dbdate_to_int:nN {#2} \l__dbdate_sub_tmpb_int
  \int_set:Nn #3 { \l__dbdate_sub_tmpa_int - \l__dbdate_sub_tmpb_int }
}
\cs_new:Nn \__dbdate_show_two:N {
  \int_compare:nNnTF {#1} > { 9 }
    { \int_use:N #1 } { 0\int_use:N #1 }
}
\cs_generate_variant:Nn \__dbdate_show_two:N { c }
\cs_new:Nn \__dbdate_use:nnnnn {
  #2\int_use:c { __dbdate_year_#1 }
  #3\int_use:c { __dbdate_month_#1 }
  #4\int_use:c { __dbdate_day_#1 }#5
}
\cs_generate_variant:Nn \__dbdate_use:nnnnn { nffff }
\cs_new:Nn \__dbdate_use_zfill:nnnnn {
  #2\int_use:c { __dbdate_year_#1 }
  #3\__dbdate_show_two:c { __dbdate_month_#1 }
  #4\__dbdate_show_two:c { __dbdate_day_#1 }#5
}
\cs_generate_variant:Nn \__dbdate_use_zfill:nnnnn { nffff }
\cs_new:Nn \__dbdate_use:nn {
  \__dbdate_use:nnnnn {#1} {} {#2} {#2} {}
}
\cs_generate_variant:Nn \__dbdate_use:nn { nf }
\cs_new:Nn \__dbdate_use_zfill:nn {
  \__dbdate_use_zfill:nnnnn {#1} {} {#2} {#2} {}
}
\cs_generate_variant:Nn \__dbdate_use_zfill:nn { nf }
\cs_new_protected:Nn \__dbdate_show:n {
  \exp_args:Nx \tl_show:n { >#1~=~\__dbdate_use:nn {#1} { - } }
}
\tl_set:Nn \dbtoday {
  \int_use:N \c_sys_year_int  \g__dbdate_sep_tl
  \int_use:N \c_sys_month_int \g__dbdate_sep_tl
  \int_use:N \c_sys_day_int
}
%% 
%%     --------------------------------------------------------------------------
%%     This package consists of the file  dbshow.dtx,
%%                  and the derived files dbshow.pdf,
%%                                        dbshow.sty,
%%                                        dbshow.ins and
%%                                        README.md.
%%
%% End of file `dbshow.sty'.
