datetime regexpression help

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf datetime regexpression help

  • Creator
    Topic
  • #48756
    Jennifer Shepard
    Participant

    Hi all,

    So I need to turn a datetime that looks like 22060831120000 into this:

    8/31/2006, 1200 Hours (i don’t need to keep seconds).

    Any regexpression experts out there that can save me from about 10 lines of code using string range and append?

    Thanks in advance,

Viewing 1 reply thread
  • Author
    Replies
    • #59583
      Charlie Bursell
      Participant

      I assume the string is really   20060831120000.  When dealing with dates I would recommend you always use the clock command.

      First you need your date in a format you can scan which means a space between date and time

      set dt 20060831120000

      regsub — {(d{8})(d+)} $dt {1 2} dt

      echo [clock format [clock scan $dt -format “%m/%d/%Y, %H%M Hours”]

      ==> 08/31/2006, 1200 Hours

      Adjust the format as needed

    • #59584
      Jamin Gray
      Participant

      If you want to just use a regsub:

      Code:


      regsub {(d{4})(d{2})(d{2})(d{4})d{2}} $date {2/3/1, 4 Hours} date

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

Forum Statistics

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