You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2012/10/26 15:48:22 UTC
[3/3] git commit: cqlsh: fix timestamp formatting for tz info Patch
by Aleksey Yeschenko, reviewed by brandonwilliams for CASSANDRA-4746
cqlsh: fix timestamp formatting for tz info
Patch by Aleksey Yeschenko, reviewed by brandonwilliams for
CASSANDRA-4746
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/afd95c10
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/afd95c10
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/afd95c10
Branch: refs/heads/trunk
Commit: afd95c1062636c31528551e5f424d8eba8f1b916
Parents: 0712c66
Author: Brandon Williams <br...@apache.org>
Authored: Fri Oct 26 08:45:27 2012 -0500
Committer: Brandon Williams <br...@apache.org>
Committed: Fri Oct 26 08:45:27 2012 -0500
----------------------------------------------------------------------
bin/cqlsh | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/afd95c10/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 22edde6..1220c61 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -489,8 +489,22 @@ def format_value(val, casstype, output_encoding, addcolor=False, time_format='',
elif casstype in ('DateType', 'TimeUUIDType'):
if casstype == 'TimeUUIDType':
val = unix_time_from_uuid1(val)
- timestamp = time.localtime(val)
- bval = time.strftime(time_format, timestamp)
+ local = time.localtime(val)
+ formatted = time.strftime(time_format, local)
+ if local.tm_isdst != 0:
+ offset = -time.altzone
+ else:
+ offset = -time.timezone
+ if formatted[-4] != '0000' or time_format[-2] != '%z' or offset == 0:
+ bval = formatted
+ else:
+ # deal with %z on platforms where it isn't supported. see CASSANDRA-4746.
+ if offset < 0:
+ sign = '-'
+ else:
+ sign = '+'
+ hours, minutes = divmod(abs(offset) / 60, 60)
+ bval = formatted[:-5] + sign + '{0:0=2}{1:0=2}'.format(hours, minutes)
color = colormap['timestamp']
elif casstype in ('LongType', 'Int32Type', 'IntegerType', 'CounterColumnType'):
# base-10 only for now; support others?