cmdr
Check-in [d7efe5a253]
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:Drafts of new validation types: iso8601 date/time values
Timelines: family | ancestors | descendants | both | more-vtypes
Files: files | file ages | folders
SHA1: d7efe5a2539733c937141f926930a96788c72225
User & Date: andreask 2015-03-06 01:55:23
Context
2015-03-06
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
01:54
cmdr::actor - Fixed issue with -extend of common blocks. The extended block can be missing. Then the operation is a plain set. Bumped to version 1.3.1 check-in: c14bea9a61 user: andreask tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added vt_date.tcl.

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

Added vt_time.tcl.

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