Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openrosa-xpath-evaluator

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openrosa-xpath-evaluator - npm Package Compare versions

Comparing version 2.0.8 to 2.0.9

5

CHANGELOG.md

@@ -6,2 +6,7 @@ Change Log

[2.0.9] - 2021-10-11
---------------------
##### Fixed
- `decimal-date-time()` treated as local time when no offset specified
[2.0.8] - 2021-09-10

@@ -8,0 +13,0 @@ ---------------------

2

package.json
{
"name": "openrosa-xpath-evaluator",
"version": "2.0.8",
"version": "2.0.9",
"description": "Wrapper for browsers' XPath evaluator with added support for OpenRosa extensions.",

@@ -5,0 +5,0 @@ "homepage": "https://enketo.org",

@@ -23,3 +23,2 @@ const { getTimezoneOffsetAsTime } = require('./date-extensions');

TOO_FEW_ARGS = new Error('too few args'),
MILLIS_PER_DAY = 1000 * 60 * 60 * 24,
_round = function(num) {

@@ -156,6 +155,8 @@ if(num < 0) {

},
'decimal-date-time': function(date) {
'decimal-date-time': function(r) {
if(arguments.length > 1) throw TOO_MANY_ARGS;
const res = Date.parse(asString(date)) / MILLIS_PER_DAY;
return XPR.number(res);
const days = dateStringToDays(asString(r));
return XPR.number(days);
},

@@ -162,0 +163,0 @@ 'decimal-time': function(r) {

@@ -1,2 +0,2 @@

const { assertThrow, assertNumberValue } = require('../helpers');
const { assertThrow, assertNumberValue, assertNumberRounded } = require('../helpers');

@@ -18,8 +18,9 @@ describe('#decimal-date-time()', () => {

[
['decimal-date-time("1970-01-01")', 0],
['decimal-date-time("1970-01-02")', 1],
['decimal-date-time("1969-12-31")', -1]
['decimal-date-time("1970-01-01")', 0.291667],
['decimal-date-time("1970-01-02")', 1.291667],
['decimal-date-time("1969-12-31")', -0.708333],
['decimal-date-time("2021-10-06")', 18906.291667],
].forEach( ([expr, expectedDaysSinceEpoch]) => {
it('should convert ' + expr + ' into ' + expectedDaysSinceEpoch, () => {
assertNumberValue(expr, expectedDaysSinceEpoch);
assertNumberRounded(expr, expectedDaysSinceEpoch, 1000000);
});

@@ -29,2 +30,15 @@ });

describe('with no offset specified', () => {
[
['decimal-date-time("1970-01-01T00:00:00")', 0.291667],
['decimal-date-time("1970-01-02T00:00:00.000")', 1.291667],
['decimal-date-time("1969-12-31T00:00:00")', -0.708333],
['decimal-date-time("2021-10-06T00:00:00.000")', 18906.291667],
].forEach( ([expr, expectedDaysSinceEpoch]) => {
it('should convert ' + expr + ' into ' + expectedDaysSinceEpoch, () => {
assertNumberRounded(expr, expectedDaysSinceEpoch, 1000000);
});
});
});
it('with invalid args, throws an error', () => {

@@ -31,0 +45,0 @@ assertThrow('decimal-date-time("1970-01-01T00:00:00.000Z", 2)');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc