clock format for precision (time)

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf clock format for precision (time)

  • Creator
    Topic
  • #51456
    Jim Kosloskey
    Participant

    I have read and re-read the clock command help.

    I do not see a format that will give me the time precision that we have come to know and love – to wit: YYYYMMDDHHMMSS[+|-]ZZZZ (for example)

    The portion I do not see covered with clock command is the [+|-]ZZZZ.

    Am I missing something or is the clock command unable to produce this precision?

    email: jim.kosloskey@jim-kosloskey.com

Viewing 5 reply threads
  • Author
    Replies
    • #70372
      David Barr
      Participant

      It looks like with TCL 8.5, you can use “%z”, but until then, you might have to use tricks like this:

      Code:

      set sec_local [clock seconds]
      set sec_gmt [clock scan [clock format $sec_local -format {%Y%m%dT%H%M%S}] -gmt 1]
      set offset [expr {abs($sec_gmt-$sec_local)/60}]
      set sign [lindex { + – } [expr $sec_gmt < $sec_local]]
      set zone "$sign[format "%02d%02d" [expr $offset/60] [expr $offset%60]]"
      echo $zone

    • #70373
      Robert Milfajt
      Participant

      I do not see it either.

      You may want to try finding some web service out there that converts the time zone abbreviation to time zone offset.  I googled time zone web service and got a lot of responses.  I browsed a few and did not find what you were looking for.

      I am sure there is some creative way using the -gmt flag to get the time in GMT and time in this location’s time zone and writing some conversion to find the offset.

      Hope this helps,

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #70374
      Jim Kosloskey
      Participant

      Okay that is what I thought – clock does not have an intrinsic format that covers the offset.

      So additional code will be needed to calculate the offset then append that to the returned value from a clock format command.

      I just wanted to make sure I was not missing something here.

      One point, when I constructed the code to calculate the offset it comes out a little different than what I would find using either the Xlate or convert_date to provide the offset.

      For example we are Central time and normally what we see in the Xlate or as a result of convert_date is ….-0600 but when I do the code I get something like …-05nn (I don’t recall the exact value I received but it was not 0600).

      So I am visiting that code some more to see if I can figure out why the discrepancy.

      email: jim.kosloskey@jim-kosloskey.com

    • #70375
      Robert Milfajt
      Participant

      This might make a useful TCL extension, perhaps an hciclock command?

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #70376
      Jim Kosloskey
      Participant

      Actually convert_date (a Cloverleaf(R) provided command) does provide the familiar offset time stamp.

      email: jim.kosloskey@jim-kosloskey.com

    • #70377
      Mary Leuchtmann
      Participant

      The offset would be -0600 for Central Standard Time, but -0500 for Central Daylight Time.

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

Forum Statistics

Registered Users
4,966
Forums
28
Topics
9,104
Replies
33,617
Topic Tags
248