clock scan

  • Creator
    Topic
  • #52195
    Kevin Crist
    Participant

      i am trying to redo our clock scan to avoid that time issue bug in that comes with it, i’ve been doing some reading and trying to get this right but coming up short, can anyone see where i’m going wrong.

      The time stamp in question is 201101060025.

      lassign $xlateInVals t1

      regsub — {(d{8})(d{2})(d{2})}  $t1 {1 2:3:4} t1

      set tout [clock format [clock scan $t1] -format “%m/%d/%Y %H:%M”]

      set xlateOutVals

        This is the error that is getting with it?

        MESSAGE 1

        Tcl callout error

        erroCode: NONE

        errorInfo:

        unable to convert date-time string “20110106 00:25:”

           while executing

        “clock scan $t1”

    Viewing 2 reply threads
    • Author
      Replies
      • #73368
        Jim Kosloskey
        Participant

          Kevin,

          I think you either need to get rid of the trailing colon or add 00 to the end for seconds.

          So if you date/time field is always only going to have time to the minutes you can just do this perhaps:

          regsub — {(d{8})(d{2})(d{2})}  $t1 {1 2:3} t1

          That should give you “20110106 00:25” and that should work.

          If, however there could be seconds or not in the input field then just check for the length of the input and if the length includes seconds do your original regsub, if it does not include seconds do the second.

          Or you can just add 00 to the end of the input if its length does not include seconds so that now it does have seconds and use your original regesub.

          Or perhaps you can just format the string to the length needed padding with zeros at the end before doing your regsub and use your original regsub.

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

        • #73369
          Charlie Bursell
          Participant

            A couple of problems here.  If you look at what your regsub returns it is:

               20110106 00:25:   (Extra colon at end)

            In addition there is a known bug in Tcl fixed in 8.5.  If you only provide four bytes for the time and time starts with 00 it can lead to problems.  You do not need the colons but lets make sure the time is 6 byes

            set t1 [format %-014s $t1]

            regsub — {(d{8})(.*)} $t1 {1 2} t1

            set tout [clock format [clock scan $t1] -format “%m/%d/%Y %H:%M”]

            You need the regsub because clock scan requires the date/time to be a two element list of “date time”  If no time then no list is required

            Note in the format statement I use s instead of d jsut in case somebody put something other than a number in there

          • #73370
            Kevin Crist
            Participant

              got it fixed.

              thanks to you both.

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