You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2019/11/07 15:12:51 UTC

[GitHub] [qpid-dispatch] ganeshmurthy commented on a change in pull request #614: DISPATCH-1439 - Added two attributes to connection and one to router.

ganeshmurthy commented on a change in pull request #614: DISPATCH-1439 - Added two attributes to connection and one to router.
URL: https://github.com/apache/qpid-dispatch/pull/614#discussion_r343703866
 
 

 ##########
 File path: python/qpid_dispatch_internal/tools/display.py
 ##########
 @@ -45,7 +45,14 @@ def Commas(value):
     sval = left
 
 def TimeLong(value):
-  return strftime("%c", gmtime(value / 1000000000))
+  day = value // (24 * 3600)
+  time = value % (24 * 3600)
+  hour = time // 3600
+  time %= 3600
+  minutes = time // 60
+  time %= 60
+  seconds = time
+  return "%03d:%02d:%02d:%02d" % (day, hour, minutes, seconds)
 
 Review comment:
   I wanted qdstat to display in days:hours:minutes:seconds (we have a 3 digit limit on the days). I assumed that the router (or a connection) will not be up for more than 999 days.
   
   That being said, strftime does not directly provide what I want. It rolls the the day into the year after 365 days. Then I need to use the year to calculate the days which becomes difficult if a leap year is involved. I could do the following and display the output in years:days:hours:minutes:seconds: 
   
   value=150000000
   year_from_epoch = strftime("%Y", gmtime(value))
   year=int(year_from_epoch) - 1970
   print ("Output=%s:%s" % (str(year), strftime("%j:%X", gmtime(value))))
   
   [gmurthy@localhost test]$ python strtime.py 
   Output=4:276:02:40:00
   [gmurthy@localhost test]$ 
   
   With all this in mind, I decided to write a simple custom function myself.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org