Merge branch 'cassandra-3.11' into trunk

This commit is contained in:
Stefania Alborghetti 2017-02-22 10:01:27 +00:00
commit 95bcaef735
2 changed files with 10 additions and 1 deletions

View File

@ -43,6 +43,7 @@
* More fixes to the TokenAllocator (CASSANDRA-12990)
* NoReplicationTokenAllocator should work with zero replication factor (CASSANDRA-12983)
Merged from 3.0:
* Fix cqlsh COPY for dates before 1900 (CASSANDRA-13185)
* Use keyspace replication settings on system.size_estimates table (CASSANDRA-9639)
* Add vm.max_map_count StartupCheck (CASSANDRA-13008)
* Obfuscate password in stress-graphs (CASSANDRA-12233)

View File

@ -356,7 +356,15 @@ def strftime(time_format, seconds, microseconds=0, timezone=None):
ret_dt = ret_dt.replace(tzinfo=UTC())
if timezone:
ret_dt = ret_dt.astimezone(timezone)
return ret_dt.strftime(time_format)
try:
return ret_dt.strftime(time_format)
except ValueError:
# CASSANDRA-13185: if the date cannot be formatted as a string, return a string with the milliseconds
# since the epoch. cqlsh does the exact same thing for values below datetime.MINYEAR (1) or above
# datetime.MAXYEAR (9999). Some versions of strftime() also have problems for dates between MIN_YEAR and 1900.
# cqlsh COPY assumes milliseconds from the epoch if it fails to parse a datetime string, and so it is
# able to correctly import timestamps exported as milliseconds since the epoch.
return '%d' % (seconds * 1000.0)
microseconds_regex = re.compile("(.*)(?:\.(\d{1,6}))(.*)")