0

I have this code which takes the values as 1hours/2hours or 3am /4pm, or 1week, 2week, 24hours etc, in time and date formats, and I have this if condition which validates for semantics :

 if {[catch {clock scan [getValue]} errMsg]} \
    {
        handleError -errMsg \
            "Invalid date-time format: $errMsg."
    }

So any other alternative for this which takes less time/uses CPU to validate the same?

vinay
  • 53
  • 1
  • 8
  • Parsing is always expensive and is going to take a lot of resources. If you can pre-convert the possible inputs, it would be faster. Is the input from a GUI or command line or ? If you can't pre-convert, perhaps you can cache results of the conversion. – Brad Lanam Dec 23 '16 at 21:00
  • @BradLanam the input is from CommandLine, how is caching of results done here? – vinay Dec 27 '16 at 06:40
  • If this is not in a loop, why are you worried about CPU/processing speed? – Brad Lanam Dec 27 '16 at 14:49

0 Answers0