@time removing colons from the strinf

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf @time removing colons from the strinf

  • Creator
    Topic
  • #48970
    Manny Zachodin
    Participant

    The format of @time is   HH:MM:SS.  How can I convert the format to HHMM (without the colon).

Viewing 3 reply threads
  • Author
    Replies
    • #60273
      Michael Lacriola
      Participant

      Here’s one method:

      tcl>echo $t

      10:35:36

      tcl>regsub -all — “:” $t {} newT

      2

      tcl>echo $newT

      103536

      tcl>set newT [csubstr $newT 0 4]

      tcl>echo $newT

      1035

      tcl>

    • #60274
      Michael Lacriola
      Participant

      andanother…a little more cryptic…

      tcl>echo $t

      10:35:36

      tcl>regsub -all — “:” [csubstr $t 0 5] {} newT

      1

      tcl>echo $newT

      1035

    • #60275
      Manny Zachodin
      Participant

      Can I invoke this small routine in xlate?

    • #60276
      Jim Kosloskey
      Participant

      Manny,

      Here is another:

      set whatsis [string map {: “”} “10:25:30”]

      echo $whatsis

      102530

      The string command is finding more favor these days since (according to Charlie Bursell and the other Tcl wizards) string is highly optimized.

      I also find many of the string commands easier to use.

      Oh and you can do this in an Xlate.

      I prefer not to imbed the code directly but rather invoke an external xltp type proc. This allows me to construct reusable code and eliminates the annoyance of when I misplace a curly brace or square bracket and get debug information which gives me everything I don;t want to know about the Xlate and always seems to stop short of telling me where in my code Tcl had objections.

      Mos timportant to me is the reusable code. Then the next time I need to do a string map, I just change the arguments to the proc. Non Tcl proficient folks can use the facility as well.

      Jim Kosloskey

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

Viewing 3 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,432
Topic Tags
286
Empty Topic Tags
10