Permalink
Browse files

fix (datetype): uses long if post-epoch date, datestring for pre, to …

  • Loading branch information...
1 parent 9e7f835 commit cb5487624d68924ed6aabd4fd5c52614c485f9ba @tim-dev tim-dev committed Nov 17, 2013
Showing with 13 additions and 9 deletions.
  1. +13 −9 lib/connection.js
View
@@ -107,17 +107,21 @@ function escapeCQL(val) {
}
if(val instanceof Date){
- if(isNaN(val.getTime())){
+ _val = val.getTime()
+ if(isNaN(_val)){
throw errors.create(new Error('Invalid Date'));
}
- // Format as an ISO date string
- return "'" + val.getUTCFullYear()
- + '-' + zero_pad(val.getUTCMonth() + 1)
- + '-' + zero_pad(val.getUTCDate())
- + ' ' + zero_pad(val.getUTCHours())
- + ':' + zero_pad(val.getUTCMinutes())
- + ':' + zero_pad(val.getUTCSeconds())
- + "'"
+ // C* < 2.0.2 doesn't work with negative longs
+ if(_val<0){
+ return "'" + val.getUTCFullYear()
+ + '-' + zero_pad(val.getUTCMonth() + 1)
+ + '-' + zero_pad(val.getUTCDate())
+ + ' ' + zero_pad(val.getUTCHours())
+ + ':' + zero_pad(val.getUTCMinutes())
+ + ':' + zero_pad(val.getUTCSeconds())
+ + "'"
+ }
+ return _val
}
if(typeof val === 'number' || typeof val === 'boolean'){

0 comments on commit cb54876

Please sign in to comment.