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.7 to 2.0.8

test/unit/date-extensions.spec.js

5

CHANGELOG.md

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

[2.0.8] - 2021-09-10
---------------------
##### Fixed
- Convert date extensions to plain functions
[2.0.7] - 2021-07-13

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

3

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

@@ -40,2 +40,3 @@ "homepage": "https://enketo.org",

"puppeteer": "^8.0.0",
"sinon": "^11.1.1",
"webpack": "^5.44.0"

@@ -42,0 +43,0 @@ },

// imported from https://github.com/enketo/enketo-xpathjs/blob/master/src/date-extensions.js
// TODO probably shouldn't be changing Date.prototype
// TODO probably shouldn't be changing Date.prototype - when these can be safely removed,
// these functions would probably more appropriately be in utils/date.js
/**
* Converts a native Date UTC String to a RFC 3339-compliant date string with local offsets
* used in ODK, so it replaces the Z in the ISOstring with a local offset
* @param {Date} date
* @return {string} a datetime string formatted according to RC3339 with local offset
*/
Date.prototype.toISOLocalString = function() {
const toISOLocalString = (date) => {
//2012-09-05T12:57:00.000-04:00 (ODK)
if(this.toString() === 'Invalid Date') {
return this.toString();
if(date.toString() === 'Invalid Date') {
return date.toString();
}
var dt = new Date(this.getTime() - (this.getTimezoneOffset() * 60 * 1000)).toISOString()
.replace('Z', this.getTimezoneOffsetAsTime());
var dt = new Date(date.getTime() - (date.getTimezoneOffset() * 60 * 1000)).toISOString()
.replace('Z', getTimezoneOffsetAsTime(date));

@@ -25,3 +28,7 @@ if(dt.indexOf('T00:00:00.000') > 0) {

Date.prototype.getTimezoneOffsetAsTime = function() {
/**
* @param {Date} date
* @return {string}
*/
const getTimezoneOffsetAsTime = (date) => {
var offsetMinutesTotal;

@@ -35,7 +42,7 @@ var hours;

if(this.toString() === 'Invalid Date') {
return this.toString();
if(date.toString() === 'Invalid Date') {
return date.toString();
}
offsetMinutesTotal = this.getTimezoneOffset();
offsetMinutesTotal = date.getTimezoneOffset();

@@ -48,1 +55,22 @@ direction = (offsetMinutesTotal < 0) ? '+' : '-';

};
/**
* @deprecated
* @see {toISOLocalString}
*/
Date.prototype.toISOLocalString = function() {
return toISOLocalString(this);
};
/**
* @deprecated
* @see {getTimezoneOffsetAsTime}
*/
Date.prototype.getTimezoneOffsetAsTime = function() {
return getTimezoneOffsetAsTime(this);
};
module.exports = {
getTimezoneOffsetAsTime,
toISOLocalString,
};

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

require('./date-extensions');
const { getTimezoneOffsetAsTime } = require('./date-extensions');
const { asGeopoints, area, distance } = require('./geo');

@@ -566,3 +566,3 @@ const digest = require('./digest');

const time = `${_zeroPad(temp[0])}-${_zeroPad(temp[1])}-${_zeroPad(temp[2])}`+
'T00:00:00.000' + (new Date(r)).getTimezoneOffsetAsTime();
'T00:00:00.000' + getTimezoneOffsetAsTime(new Date(r));
return new Date(time);

@@ -569,0 +569,0 @@ }

const { DATE_STRING, dateToDays, dateStringToDays } = require('./date');
const { toISOLocalString } = require('../date-extensions');

@@ -37,3 +38,3 @@ module.exports = {

case 'arr': return r.v.length ? r.v[0].textContent || '' : '';
case 'date': return r.v.toISOLocalString().replace(/T00:00:00.000.*/, ''); // TODO should be handled in an extension rather than core code
case 'date': return toISOLocalString(r.v).replace(/T00:00:00.000.*/, ''); // TODO should be handled in an extension rather than core code
case 'num':

@@ -40,0 +41,0 @@ case 'bool':

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