Skip to content

Commit cd4b7d0

Browse files
committed
Fix date problem
1 parent c58e4ae commit cd4b7d0

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const rsqlMongoDB = require('rsql-mongodb');
3636

3737
try{
3838

39-
// String comparison : you have to add quotes for string values
39+
// String comparison : you can add quotes for string values
4040
rsqlMongoDB('lastName=="doe"');
4141
//=> { "lastName" : "doe" }
4242

@@ -50,7 +50,7 @@ try{
5050

5151
// Date comparison
5252
rsqlMongoDB('birthday=ge=1959-10-21');
53-
//=> { "birthday": { $gte: new Date("1959-10-21") } }
53+
//=> { "birthday": { $gte: new Date("1959-10-21T00:00:00.000Z") } }
5454

5555
// In comparison
5656
rsqlMongoDB('childs=in=(1,2,3)');
@@ -61,7 +61,7 @@ try{
6161
//=> { "childs": { $nin: [1,2,3] } }
6262

6363
// Groups
64-
rsqlMongoDB('(firstName=="john";lastName=="doe"),(firstName=="janne";lastName=="doe")');
64+
rsqlMongoDB('(firstName=="john";lastName=="doe"),(firstName==janne;lastName==doe)');
6565
//=> { $or: [ { $and: [ { "firstName" : "john" } , { "lastName" : "doe" } ] } , { $and: [ { "firstName" : "janne" } , { "lastName" : "doe" } ] } ] }
6666

6767
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rsql-mongodb",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Converting RSQL queries to MongoDB queries",
55
"main": "rsql-mongodb.js",
66
"typings": "rsql-mongodb.ts",

rsql-mongodb.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ function setType(input) {
2020
}
2121
else if(matchDate.exec(input)){
2222
if(Date.parse(input)){
23-
typedInput = new Date('"' + input + '"');
23+
var isoUTCDate = new Date(input).toISOString();
24+
typedInput = new Date('"' + isoUTCDate + '"');
2425
}
2526
}
2627

0 commit comments

Comments
 (0)