openrosa-xpath-evaluator
Advanced tools
Comparing version 1.4.1 to 1.4.2
{ | ||
"name": "openrosa-xpath-evaluator", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Wrapper for browsers' XPath evaluator with added support for OpenRosa extensions.", | ||
@@ -5,0 +5,0 @@ "main": "src/openrosa-xpath.js", |
@@ -5,3 +5,3 @@ var openrosa_xpath_extensions = function(translate) { | ||
RAW_NUMBER = /^(-?[0-9]+)(\.[0-9]+)?$/, | ||
DATE_STRING = /^\d\d\d\d-\d\d-\d\d(?:T\d\d:\d\d:\d\d(?:Z|[+-]\d\d:\d\d))?$/, | ||
DATE_STRING = /^\d\d\d\d-\d{1,2}-\d{1,2}(?:T\d\d:\d\d:\d\d(?:Z|[+-]\d\d:\d\d))?$/, | ||
XPR = { | ||
@@ -36,8 +36,9 @@ boolean: function(val) { return { t:'bool', v:val }; }, | ||
_uuid_part = function(c) { | ||
var r = Math.random()*16|0, | ||
v=c=='x'?r:r&0x3|0x8; | ||
return v.toString(16); | ||
// TODO understand what these are used for - they're probably not very unique | ||
var r = Math.random()*16|0, | ||
v = c == 'x' ? r : r&0x3|0x8; | ||
return v.toString(16); | ||
}, | ||
_parseDate = function(it) { | ||
var temp; | ||
var temp, t; | ||
if(it instanceof Date) { | ||
@@ -51,3 +52,5 @@ return new Date(it); | ||
} else if(DATE_STRING.test(it)) { | ||
temp = it.substring(0, 10).split('-'); | ||
t = it.indexOf('T'); | ||
if(t !== -1) it = it.substring(0, t); | ||
temp = it.split('-'); | ||
temp = new Date(temp[0], temp[1]-1, temp[2]); | ||
@@ -54,0 +57,0 @@ return temp; |
@@ -155,2 +155,8 @@ define(['src/openrosa-xpath-extensions', 'src/extended-xpath', 'src/translate', 'chai', 'lodash'], | ||
describe('date string with single-digit day or month values', function() { | ||
it('should insert zeroes', function() { | ||
assert.equal(xEval("date('1970-1-2')").stringValue, '1970-01-02'); | ||
}); | ||
}); | ||
describe('number', function() { | ||
@@ -157,0 +163,0 @@ _.forEach({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
151624
2512