You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jm...@apache.org on 2016/02/19 20:44:49 UTC

cassandra git commit: ninja 10397 - cqlsh: Fix sub second precision support

Repository: cassandra
Updated Branches:
  refs/heads/trunk acb2ab072 -> 07df8a22d


ninja 10397 - cqlsh: Fix sub second precision support


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/07df8a22
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/07df8a22
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/07df8a22

Branch: refs/heads/trunk
Commit: 07df8a22d1a9c048cdbe3f9484c09f1bf118629e
Parents: acb2ab0
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Thu Feb 18 23:03:28 2016 -0300
Committer: Joshua McKenzie <jm...@apache.org>
Committed: Fri Feb 19 14:44:52 2016 -0500

----------------------------------------------------------------------
 pylib/cqlshlib/formatting.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/07df8a22/pylib/cqlshlib/formatting.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py
index 6b88bc7..f88d936 100644
--- a/pylib/cqlshlib/formatting.py
+++ b/pylib/cqlshlib/formatting.py
@@ -238,14 +238,18 @@ formatter_for('int')(format_integer_type)
 
 @formatter_for('datetime')
 def format_value_timestamp(val, colormap, date_time_format, quote=False, **_):
-    bval = strftime(date_time_format.timestamp_format, calendar.timegm(val.utctimetuple()), timezone=date_time_format.timezone)
+    bval = strftime(date_time_format.timestamp_format,
+                    calendar.timegm(val.utctimetuple()),
+                    microseconds=val.microsecond,
+                    timezone=date_time_format.timezone)
     if quote:
         bval = "'%s'" % bval
     return colorme(bval, colormap, 'timestamp')
 
 
-def strftime(time_format, seconds, timezone=None):
-    ret_dt = datetime_from_timestamp(seconds).replace(tzinfo=UTC())
+def strftime(time_format, seconds, microseconds=0, timezone=None):
+    ret_dt = datetime_from_timestamp(seconds) + datetime.timedelta(microseconds=microseconds)
+    ret_dt = ret_dt.replace(tzinfo=UTC())
     if timezone:
         ret_dt = ret_dt.astimezone(timezone)
     return ret_dt.strftime(time_format)