• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. ISO 8601 timestamp

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 14712
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ISO 8601 timestamp

Yaosan Yeo
Yaosan Yeo over 13 years ago

I'm trying to work with timestamp in ISO 8601 format. The timestamp looks like this: "2012-08-07T16:38:45.693245Z". I want to construct a report field which displays this date in one of the columns. I know in SKILL the standard time string looks more like this: "Aug  1 12:00:32 2012". Is there an easy way to convert my input time string to the time string SKILL recognize?

I've tried to format the input time string then use "date" in command line to convert the time stamp but it is really really slow:

date -d "2012-08-07 16:38:45.693245 UTC" "+%b %_d %k:%m:%S %Y"

Is there another way around this problem? Thanks!

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 13 years ago

    I just wrote this - it uses the pcre (Perl Compatible Regular Expression) functions (in IC61) to parse the ISO 8601 format date string, and then the "tm" functions to convert to and from a time structure - and then to a SKILL date string. May need some further work because I just threw this together...

    /* abISO8601.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Aug 08, 2012 
    Modified   
    By         
    
    Functions to convert dates in ISO8601 format to either "tm"
    structures or a SKILL date string.
    
    Note that this doesn't handle time zones - so may need some
    adjustment for timezones / daylight saving time (not sure).
    
    ***************************************************
    
    SCCS Info: @(#) abISO8601.il 08/08/12.06:36:34 1.1
    
    */
    
    /***************************************************************
    *                                                              *
    *                  (abISO8601toTm dateString)                  *
    *                                                              *
    * Attempts to convert an ISO8601 formatted date string into a  *
    *                       "tm" structure.                        *
    *                                                              *
    ***************************************************************/
    
    (defun abISO8601toTm (dateString)
      (let (pattern tm slot)
        ;--------------------------------------------------------------------
        ; Note ignores anything after decimal point in seconds, as time
        ; functions in SKILL do not support finer granularity. Also the
        ; time zone is ignored. The pattern below should support both
        ; basic and extended format
        ;--------------------------------------------------------------------
        (setq pattern (pcreCompile
                        "(\\d{4})-?(\\d{2})-?(\\d{2})[T ]?(\\d{2}):?(\\d{2}):?(\\d{2})"
                        ))
        (when
          (pcreExecute pattern dateString)
          ;------------------------------------------------------------------
          ; Create an "empty" tm structure
          ;------------------------------------------------------------------
          (setq tm (timeToTm 0))
          (setq slot 1)
          (foreach (field correction) 
                   '(tm_year tm_mon tm_mday tm_hour tm_min tm_sec)
                   '(1900 1 0 0 0 0)
                   ;---------------------------------------------------------
                   ; Pull out each field from the pattern, convert to
                   ; integer, and apply a correction (subtraction) 
                   ; and then store in the correct field in the tm
                   ; structure
                   ;---------------------------------------------------------
                   (putprop tm (difference
                                 (atoi (pcreSubstitute
                                         pattern 
                                         (sprintf nil "\\%d" (postincrement slot))))
                                 correction)
                            field)
                   )
          ;------------------------------------------------------------------
          ; could do timeToTm(tmToTime(tm)) here to fill in other fields
          ; but doesn't seem really necessary
          ;------------------------------------------------------------------
          tm
          )
        )
      )
    
    /****************************************************************
    *                                                               *
    *                (abISO8601toString dateString)                 *
    *                                                               *
    * Convert an ISO8601 date string into SKILL's usual date format *
    *                                                               *
    ****************************************************************/
    
    (defun abISO8601toString (dateString)
      (timeToString (tmToTime (abISO8601toTm dateString)))
      )

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 13 years ago

    I just wrote this - it uses the pcre (Perl Compatible Regular Expression) functions (in IC61) to parse the ISO 8601 format date string, and then the "tm" functions to convert to and from a time structure - and then to a SKILL date string. May need some further work because I just threw this together...

    /* abISO8601.il
    
    Author     A.D.Beckett
    Group      Custom IC (UK), Cadence Design Systems Ltd.
    Language   SKILL
    Date       Aug 08, 2012 
    Modified   
    By         
    
    Functions to convert dates in ISO8601 format to either "tm"
    structures or a SKILL date string.
    
    Note that this doesn't handle time zones - so may need some
    adjustment for timezones / daylight saving time (not sure).
    
    ***************************************************
    
    SCCS Info: @(#) abISO8601.il 08/08/12.06:36:34 1.1
    
    */
    
    /***************************************************************
    *                                                              *
    *                  (abISO8601toTm dateString)                  *
    *                                                              *
    * Attempts to convert an ISO8601 formatted date string into a  *
    *                       "tm" structure.                        *
    *                                                              *
    ***************************************************************/
    
    (defun abISO8601toTm (dateString)
      (let (pattern tm slot)
        ;--------------------------------------------------------------------
        ; Note ignores anything after decimal point in seconds, as time
        ; functions in SKILL do not support finer granularity. Also the
        ; time zone is ignored. The pattern below should support both
        ; basic and extended format
        ;--------------------------------------------------------------------
        (setq pattern (pcreCompile
                        "(\\d{4})-?(\\d{2})-?(\\d{2})[T ]?(\\d{2}):?(\\d{2}):?(\\d{2})"
                        ))
        (when
          (pcreExecute pattern dateString)
          ;------------------------------------------------------------------
          ; Create an "empty" tm structure
          ;------------------------------------------------------------------
          (setq tm (timeToTm 0))
          (setq slot 1)
          (foreach (field correction) 
                   '(tm_year tm_mon tm_mday tm_hour tm_min tm_sec)
                   '(1900 1 0 0 0 0)
                   ;---------------------------------------------------------
                   ; Pull out each field from the pattern, convert to
                   ; integer, and apply a correction (subtraction) 
                   ; and then store in the correct field in the tm
                   ; structure
                   ;---------------------------------------------------------
                   (putprop tm (difference
                                 (atoi (pcreSubstitute
                                         pattern 
                                         (sprintf nil "\\%d" (postincrement slot))))
                                 correction)
                            field)
                   )
          ;------------------------------------------------------------------
          ; could do timeToTm(tmToTime(tm)) here to fill in other fields
          ; but doesn't seem really necessary
          ;------------------------------------------------------------------
          tm
          )
        )
      )
    
    /****************************************************************
    *                                                               *
    *                (abISO8601toString dateString)                 *
    *                                                               *
    * Convert an ISO8601 date string into SKILL's usual date format *
    *                                                               *
    ****************************************************************/
    
    (defun abISO8601toString (dateString)
      (timeToString (tmToTime (abISO8601toTm dateString)))
      )

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information