duanguoxue / tstools

Automatically exported from code.google.com/p/tstools
0 stars 0 forks source link

"hms" format timestamps have extra zero padding in milliseconds #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Run tsreport -b -tafmt hms tfmt hms file.ts

Note that the timestamps are actually hh:mm:ss.0nnn where nnn is the 
milliseconds, making the milliseconds part appear only one tenth of what it 
should be, 

Here's a very small diff which corrects this:

diff --git a/fmtx.c b/fmtx.c
index dd250b6..b8c30b5 100644
--- a/fmtx.c
+++ b/fmtx.c
@@ -93,7 +93,7 @@ const TCHAR *fmtx_timestamp(int64_t n, unsigned int flags)
       a27 /= I64K(60);
       m = (unsigned int)(a27 % I64K(60));
       h = (unsigned int)(a27 / I64K(60));
-      _stprintf(buf, _T("%s%u:%02u:%02u.%04u"), n27 < 0 ? _T("-") : _T(""), h, 
m, s, f/1000);
+      _stprintf(buf, _T("%s%u:%02u:%02u.%03u"), n27 < 0 ? _T("-") : _T(""), h, 
m, s, f/1000);
       break;
     }

Original issue reported on code.google.com by piers.sc...@ericsson.com on 4 Mar 2013 at 5:30

GoogleCodeExporter commented 9 years ago
An updated diff following changes to the trunk. (This is a really simple fix 
and obvious bug - surprised it's not been incorporated already.)

diff --git a/fmtx.c b/fmtx.c
index c0fd4a0..22101ea 100644
--- a/fmtx.c
+++ b/fmtx.c
@@ -93,7 +93,7 @@ const TCHAR *fmtx_timestamp(int64_t n, unsigned int flags)
       a27 /= I64K(60);
       m = (unsigned int)(a27 % I64K(60));
       h = (unsigned int)(a27 / I64K(60));
-      _sntprintf(buf, FMTX_BUFFER_SIZE, _T("%s%u:%02u:%02u.%04u"), n27 < 0 ? 
_T("-") : _T(""), h, m, s, f/1000);
+      _sntprintf(buf, FMTX_BUFFER_SIZE, _T("%s%u:%02u:%02u.%03u"), n27 < 0 ? 
_T("-") : _T(""), h, m, s, f/1000);
       break;
     }

Original comment by piers.sc...@ericsson.com on 29 Jul 2013 at 10:30

GoogleCodeExporter commented 9 years ago
Exported project and fixed this at: https://github.com/PiersEBMS/tstools 

Original comment by piers.sc...@ericsson.com on 11 Apr 2015 at 1:44