You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Ben Boule (JIRA)" <ji...@apache.org> on 2013/08/09 20:16:48 UTC
[jira] [Commented] (CASSANDRA-5870) CQLSH not showing milliseconds
in timestamps
[ https://issues.apache.org/jira/browse/CASSANDRA-5870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13735093#comment-13735093 ]
Ben Boule commented on CASSANDRA-5870:
--------------------------------------
--- formatting.py 2013-08-09 13:38:16.608551610 -0400
+++ formatting.py 2013-08-09 13:54:47.544863339 -0400
@@ -156,7 +156,7 @@
def strftime(time_format, seconds):
local = time.localtime(seconds)
- formatted = time.strftime(time_format, local)
+ formatted = formatWithMs(time_format, local, seconds)
if local.tm_isdst != 0:
offset = -time.altzone
else:
@@ -171,6 +171,18 @@
hours, minutes = divmod(abs(offset) / 60, 60)
return formatted[:-5] + sign + '{0:0=2}{1:0=2}'.format(hours, minutes)
+def formatWithMs(time_format,timeval,seconds):
+ if "%S" not in time_format:
+ return time.strftime(time_format,timeval)
+
+ segments = time_format.partition("%S")
+ return time.strftime(segments[0],timeval) + \
+ time.strftime(segments[1],timeval) + "." + getMSeconds(seconds) + \
+ time.strftime(segments[2],timeval)
+
+def getMSeconds(seconds):
+ return "{0:.0f}".format((seconds * 1000) % 1000)
+
@formatter_for('text')
def format_value_text(val, encoding, colormap, **_):
escapedval = val.replace(u'\\', u'\\\\')
> CQLSH not showing milliseconds in timestamps
> --------------------------------------------
>
> Key: CASSANDRA-5870
> URL: https://issues.apache.org/jira/browse/CASSANDRA-5870
> Project: Cassandra
> Issue Type: Bug
> Components: Tools
> Environment: Linux
> Reporter: Ben Boule
> Priority: Minor
> Fix For: 1.2.5
>
>
> CQLSH does not include the milliseconds portion of the timestamp when outputting query results. For example on my system a time might be displayed like this:
> "2013-08-09 10:55:58-0400" for a time stored in cassandra as: 1376060158267
> We've found this extremely annoying when dealing with time series data as it will make records which occurred at different times appear to occur at the same time.
> I'm submitting a patch, the existing formatting code already has handling of some versions of python which do not support formatting time zones, I'm not sure which versions of python can format seconds+milliseconds so I attempted to supply something which will work with any time_format string and does not depend on the system library.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira