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 Unified Diffs Show Whitespace Changes Patch

Added vt_date.tcl.




































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## CMDR - Validate::Date - Supporting validation type - iso dates.

# @@ Meta Begin
# Package cmdr::validate::date 0
# Meta author   {Andreas Kupries}
# Meta location https://core.tcl.tk/akupries/cmdr
# Meta platform tcl
# Meta summary     Standard parameter validation type for dates
# Meta description Standard parameter validation type for dates
# Meta subject {command line}
# Meta require {Tcl 8.5-}
# Meta require {cmdr::validate::common 1.2}
# Meta require debug
# Meta require debug::caller
# @@ Meta End

# # ## ### ##### ######## ############# #####################
## Requisites

package require Tcl 8.5
package require cmdr::validate::common 1.2
package require debug
package require debug::caller

package require clock::iso8601
package require try

# # ## ### ##### ######## ############# #####################
## Definition

namespace eval ::cmdr {
    namespace export validate
    namespace ensemble create
}
namespace eval ::cmdr::validate {
    namespace export date
    namespace ensemble create
}
namespace eval ::cmdr::validate::date {
    namespace export default validate complete release
    namespace ensemble create

    namespace import ::cmdr::validate::common::fail
}

# # ## ### ##### ######## ############# #####################

debug define cmdr/validate/date
debug level  cmdr/validate/date
debug prefix cmdr/validate/date {[debug caller] | }

# # ## ### ##### ######## ############# #####################
## Dates as parsed by clock::iso86

proc ::cmdr::validate::date::release  {p x} { return }
proc ::cmdr::validate::date::default  {p}  {
    debug.cmdr/validate/date {}
    # Today.
    return [clock format [clock seconds] -format {%Y-%m-%d}]
}
proc ::cmdr::validate::date::complete {p x} {
    debug.cmdr/validate/date {} 10
    # No completion.
    return {}
}
proc ::cmdr::validate::date::validate {p x} {
    debug.cmdr/validate/date {}
    try {
	# TODO: error code in clock::iso8601.
	set epoch [clock::iso8601 parse_date $x]
    } on error {e o} {
	fail $p DATE "an ISO8601 date" $x
    } 
    return $epoch
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate::date 1
return

Added vt_time.tcl.




































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## CMDR - Validate::Time - Supporting validation type - iso times.

# @@ Meta Begin
# Package cmdr::validate::time 0
# Meta author   {Andreas Kupries}
# Meta location https://core.tcl.tk/akupries/cmdr
# Meta platform tcl
# Meta summary     Standard parameter validation type for times
# Meta description Standard parameter validation type for times
# Meta subject {command line}
# Meta require {Tcl 8.5-}
# Meta require {cmdr::validate::common 1.2}
# Meta require debug
# Meta require debug::caller
# @@ Meta End

# # ## ### ##### ######## ############# #####################
## Requisites

package require Tcl 8.5
package require cmdr::validate::common 1.2
package require debug
package require debug::caller

package require clock::iso8601
package require try

# # ## ### ##### ######## ############# #####################
## Definition

namespace eval ::cmdr {
    namespace export validate
    namespace ensemble create
}
namespace eval ::cmdr::validate {
    namespace export time
    namespace ensemble create
}
namespace eval ::cmdr::validate::time {
    namespace export default validate complete release
    namespace ensemble create

    namespace import ::cmdr::validate::common::fail
}

# # ## ### ##### ######## ############# #####################

debug define cmdr/validate/time
debug level  cmdr/validate/time
debug prefix cmdr/validate/time {[debug caller] | }

# # ## ### ##### ######## ############# #####################
## Times as parsed by clock::iso86

proc ::cmdr::validate::time::release  {p x} { return }
proc ::cmdr::validate::time::default  {p}  {
    debug.cmdr/validate/time {}
    # Today.
    return [clock format [clock seconds] -format {%Y-%m-%d}]
}
proc ::cmdr::validate::time::complete {p x} {
    debug.cmdr/validate/time {} 10
    # No completion.
    return {}
}
proc ::cmdr::validate::time::validate {p x} {
    debug.cmdr/validate/time {}
    try {
	# TODO: error code in clock::iso8601.
	set epoch [clock::iso8601 parse_time $x]
    } on error {e o} {
	fail $p TIME "an ISO8601 time" $x
    } 
    return $epoch
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate::time 1
return