[
https://issues.apache.org/jira/browse/CASSANDRA-10000?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14660175#comment-14660175
]
Paulo Motta commented on CASSANDRA-10000:
-----------------------------------------
The problem here is that cqlsh [current
implementation|https://github.com/apache/cassandra/blob/cassandra-2.2.0-rc1/pylib/cqlshlib/formatting.py#L186]
displays timestamps in the local timezone, with the use of python's
[time.localtime(secs)|https://docs.python.org/2/library/time.html#time.localtime]
function. However, this function does not work on non-unix systems for
pre-epoch times (before 1970-01-01):
{noformat}
C:\> python -c 'import time; time.localtime(-1)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: (22, 'Invalid argument')
{noformat}
In order to keep the current behavior of displaying dates in the local timezone
in non-Unix systems, we would need to budle and regularly update an external
library, such as pytz, into cqlsh, since python does not provide an standard
implementation of
[timezone|https://docs.python.org/3/library/datetime.html#datetime.tzinfo].
In order to keep things simple, we opted for displaying dates in UTC in cqlsh
while not adding additional dependencies to cqlsh. If there's demand, we could
later add an option to cqlsh to display dates in the local timezone, if the
user has the pytz library installed locally.
* Patch for 2.2 available
[here|https://github.com/pauloricardomg/cassandra/tree/10000-2.2].
* Dtest added [here|https://github.com/riptano/cassandra-dtest/pull/442].
*
[testall|http://cassci.datastax.com/view/Dev/view/paulomotta/job/pauloricardomg-10000-2.2-testall/]
(still running)
*
[dtests|http://cassci.datastax.com/view/Dev/view/paulomotta/job/pauloricardomg-10000-2.2-dtest/]
(still running)
> Dates before 1970-01-01 are not formatted correctly on cqlsh\Windows
> --------------------------------------------------------------------
>
> Key: CASSANDRA-10000
> URL: https://issues.apache.org/jira/browse/CASSANDRA-10000
> Project: Cassandra
> Issue Type: Bug
> Environment: windows
> Reporter: Paulo Motta
> Assignee: Paulo Motta
> Priority: Minor
> Labels: cqlsh, windows
> Fix For: 2.2.x
>
>
> The following test fails on Windows:
> {code:none}
> def test_past_and_future_dates(self):
> self.cluster.populate(1)
> self.cluster.start(wait_for_binary_proto=True)
> node1, = self.cluster.nodelist()
> node1.run_cqlsh(cmds="""
> CREATE KEYSPACE simple WITH replication = {'class':
> 'SimpleStrategy', 'replication_factor': 1};
> use simple;
> create TABLE simpledate (id int PRIMARY KEY , value timestamp ) ;
> insert into simpledate (id, value) VALUES (1,
> '2143-04-19T11:21:01+0000');
> insert into simpledate (id, value) VALUES (2,
> '1943-04-19T11:21:01+0000')""")
> session = self.patient_cql_connection(node1)
> rows = session.execute("select id, value from simple.simpledate")
> output, err = self.run_cqlsh(node1, 'use simple; SELECT * FROM
> simpledate')
> self.assertIn("2143-04", output)
> self.assertIn("1943-04", output)
> {code}
> With the following message:
> {noformat}
> AssertionError: '1943-04' not found in "\r\n id |
> value\r\n----+-------------------------------------------\r\n 1 |
> 2143-04-19 08:21:01.-0300\r\n 2 | datetime.datetime(1943, 4, 19, 11,
> 21, 1)\r\n\r\n(2 rows)\r\nFailed to format value datetime.datetime(1943, 4,
> 19, 11, 21, 1) : (22, 'Invalid argument')\r\n"
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)