cmdr
Check-in [d993d2bda7]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes (defaults, metadata) and extensions (2external) for date/time
Timelines: family | ancestors | descendants | both | more-vtypes
Files: files | file ages | folders
SHA1: d993d2bda781e4e63672d0ca4ff169c5e8e796ae
User & Date: aku 2015-03-06 19:13:47
Context
2015-03-06
19:14
And more vtypes: positive ints, years, and weekdays check-in: 307a15e657 user: aku tags: more-vtypes
19:13
fixes (defaults, metadata) and extensions (2external) for date/time check-in: d993d2bda7 user: aku tags: more-vtypes
01:55
Drafts of new validation types: iso8601 date/time values check-in: d7efe5a253 user: andreask tags: more-vtypes
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to vt_date.tcl.

     1      1   ## -*- tcl -*-
     2      2   # # ## ### ##### ######## ############# #####################
     3      3   ## CMDR - Validate::Date - Supporting validation type - iso dates.
     4      4   
     5      5   # @@ Meta Begin
     6         -# Package cmdr::validate::date 0
            6  +# Package cmdr::validate::date 1
     7      7   # Meta author   {Andreas Kupries}
     8      8   # Meta location https://core.tcl.tk/akupries/cmdr
     9      9   # Meta platform tcl
    10     10   # Meta summary     Standard parameter validation type for dates
    11     11   # Meta description Standard parameter validation type for dates
    12     12   # Meta subject {command line}
    13     13   # Meta require {Tcl 8.5-}
    14     14   # Meta require {cmdr::validate::common 1.2}
    15     15   # Meta require debug
    16     16   # Meta require debug::caller
           17  +# Meta require try
           18  +# Meta require clock::iso8601
    17     19   # @@ Meta End
    18     20   
    19     21   # # ## ### ##### ######## ############# #####################
    20     22   ## Requisites
    21     23   
    22     24   package require Tcl 8.5
    23     25   package require cmdr::validate::common 1.2
................................................................................
    35     37       namespace ensemble create
    36     38   }
    37     39   namespace eval ::cmdr::validate {
    38     40       namespace export date
    39     41       namespace ensemble create
    40     42   }
    41     43   namespace eval ::cmdr::validate::date {
    42         -    namespace export default validate complete release
           44  +    namespace export default validate complete release 2external
    43     45       namespace ensemble create
    44     46   
    45     47       namespace import ::cmdr::validate::common::fail
    46     48   }
    47     49   
    48     50   # # ## ### ##### ######## ############# #####################
    49     51   
    50     52   debug define cmdr/validate/date
    51     53   debug level  cmdr/validate/date
    52     54   debug prefix cmdr/validate/date {[debug caller] | }
    53     55   
    54     56   # # ## ### ##### ######## ############# #####################
    55     57   ## Dates as parsed by clock::iso86
           58  +
           59  +proc ::cmdr::validate::date::2external {x}  {
           60  +    debug.cmdr/validate/date {}
           61  +    return [clock format $x -format {%Y-%m-%d}]
           62  +}
    56     63   
    57     64   proc ::cmdr::validate::date::release  {p x} { return }
    58     65   proc ::cmdr::validate::date::default  {p}  {
    59     66       debug.cmdr/validate/date {}
    60     67       # Today.
    61         -    return [clock format [clock seconds] -format {%Y-%m-%d}]
           68  +    return [clock seconds]
    62     69   }
    63     70   proc ::cmdr::validate::date::complete {p x} {
    64     71       debug.cmdr/validate/date {} 10
    65     72       # No completion.
    66     73       return {}
    67     74   }
    68     75   proc ::cmdr::validate::date::validate {p x} {

Changes to vt_time.tcl.

     1      1   ## -*- tcl -*-
     2      2   # # ## ### ##### ######## ############# #####################
     3      3   ## CMDR - Validate::Time - Supporting validation type - iso times.
     4      4   
     5      5   # @@ Meta Begin
     6         -# Package cmdr::validate::time 0
            6  +# Package cmdr::validate::time 1
     7      7   # Meta author   {Andreas Kupries}
     8      8   # Meta location https://core.tcl.tk/akupries/cmdr
     9      9   # Meta platform tcl
    10     10   # Meta summary     Standard parameter validation type for times
    11     11   # Meta description Standard parameter validation type for times
    12     12   # Meta subject {command line}
    13     13   # Meta require {Tcl 8.5-}
    14     14   # Meta require {cmdr::validate::common 1.2}
    15     15   # Meta require debug
    16     16   # Meta require debug::caller
           17  +# Meta require try
           18  +# Meta require clock::iso8601
    17     19   # @@ Meta End
    18     20   
    19     21   # # ## ### ##### ######## ############# #####################
    20     22   ## Requisites
    21     23   
    22     24   package require Tcl 8.5
    23     25   package require cmdr::validate::common 1.2
................................................................................
    35     37       namespace ensemble create
    36     38   }
    37     39   namespace eval ::cmdr::validate {
    38     40       namespace export time
    39     41       namespace ensemble create
    40     42   }
    41     43   namespace eval ::cmdr::validate::time {
    42         -    namespace export default validate complete release
           44  +    namespace export default validate complete release 2external
    43     45       namespace ensemble create
    44     46   
    45     47       namespace import ::cmdr::validate::common::fail
    46     48   }
    47     49   
    48     50   # # ## ### ##### ######## ############# #####################
    49     51   
    50     52   debug define cmdr/validate/time
    51     53   debug level  cmdr/validate/time
    52     54   debug prefix cmdr/validate/time {[debug caller] | }
    53     55   
    54     56   # # ## ### ##### ######## ############# #####################
    55     57   ## Times as parsed by clock::iso86
           58  +
           59  +proc ::cmdr::validate::time::2external {x}  {
           60  +    debug.cmdr/validate/time {}
           61  +    return [clock format $x -format {%H:%M:%S}]
           62  +}
    56     63   
    57     64   proc ::cmdr::validate::time::release  {p x} { return }
    58     65   proc ::cmdr::validate::time::default  {p}  {
    59     66       debug.cmdr/validate/time {}
    60     67       # Today.
    61         -    return [clock format [clock seconds] -format {%Y-%m-%d}]
           68  +    return [clock seconds]
    62     69   }
    63     70   proc ::cmdr::validate::time::complete {p x} {
    64     71       debug.cmdr/validate/time {} 10
    65     72       # No completion.
    66     73       return {}
    67     74   }
    68     75   proc ::cmdr::validate::time::validate {p x} {