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

timezoned-date

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timezoned-date - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

100

lib/index.js

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

(function (root, factory) {
(function(root, factory) {
if (typeof module !== 'undefined' && module.exports) {

@@ -9,9 +9,7 @@ module.exports = factory();

}
})(this, function () {
})(this, function() {
'use strict';
var MILLISECONDS_PER_MINUTE = 60 * 1000,
// YYYY-MM-DD strings are parsed as UTC. See http://dygraphs.com/date-formats.html
TIMEZONED_STRING = /^\d\d\d\d(-\d\d){0,2}($|T)|(((GMT)?[\+\-]\d\d:?\d\d)|Z)(\s*\(.+\))?$|([ECMP][SD]|GM|U)T[\s\/-]*$/,
// YYYY-MM-DD strings are parsed as UTC. See http://dygraphs.com/date-formats.html
TIMEZONED_STRING = /^\d\d\d\d(-\d\d){0,2}($|T)|(((GMT)?[\+\-]\d\d:?\d\d)|Z)(\s*\(.+\))?$|([ECMP][SD]|GM|U)T[\s\/-]*$/,
daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],

@@ -21,5 +19,5 @@ months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],

nativeProto = NativeDate.prototype,
isStrict = function () {
return !this;
}();
isStrict = (function() {
return !this;
})();
function makeConstructor(offset) {

@@ -42,3 +40,8 @@ if (offset === undefined) {

instance = new NativeDate(a0);
var done = isInvalidDate(instance) || a0 == null || a0 instanceof NativeDate || typeof a0 === 'number' || typeof a0 === 'boolean';
var done =
isInvalidDate(instance) ||
a0 == null ||
a0 instanceof NativeDate ||
typeof a0 === 'number' ||
typeof a0 === 'boolean';
if (!done && typeof a0 !== 'string') {

@@ -64,3 +67,6 @@ // According to the ES specification, a0 should be converted to a string or a number

// however means that we can get a value off by 1 hour because of DST.
time = instance.getTime() - nativeProto.getTimezoneOffset.apply(instance) * MILLISECONDS_PER_MINUTE - offsetInMilliseconds;
time =
instance.getTime() -
nativeProto.getTimezoneOffset.apply(instance) * MILLISECONDS_PER_MINUTE -
offsetInMilliseconds;
instance.setTime(time);

@@ -76,4 +82,6 @@ }

setPrototypeOf(instance, proto);
if ( // Trying to pass this tricky test: test262\test\built-ins\Date\subclassing.js
this.constructor !== Constructor) {
if (
// Trying to pass this tricky test: test262\test\built-ins\Date\subclassing.js
this.constructor !== Constructor
) {
var newTargetPrototype = Object.getPrototypeOf(this);

@@ -90,4 +98,8 @@ if (newTargetPrototype !== Object.prototype) {

var result = NativeDate.UTC.apply(NativeDate, arguments);
if ( // Node doesn't pass test262/test/built-ins/Date/UTC/return-value.js
result !== result && arguments.length === 1 && typeof a0 === 'number') {
if (
// Node doesn't pass test262/test/built-ins/Date/UTC/return-value.js
result !== result &&
arguments.length === 1 &&
typeof a0 === 'number'
) {
result = NativeDate.UTC(a0, 0);

@@ -115,4 +127,6 @@ }

}
if ( // Don't return -0
offset === 0) {
if (
// Don't return -0
offset === 0
) {
return 0;

@@ -126,3 +140,8 @@ }

}
return [daysOfWeek[this.getDay()], months[this.getMonth()], addZero(this.getDate()), padYear(this.getFullYear())].join(' ');
return [
daysOfWeek[this.getDay()],
months[this.getMonth()],
addZero(this.getDate()),
padYear(this.getFullYear())
].join(' ');
},

@@ -133,3 +152,11 @@ toTimeString: function toTimeString() {

}
return [addZero(this.getHours()), ':', addZero(this.getMinutes()), ':', addZero(this.getSeconds()), ' ', formatOffset(offset)].join('');
return [
addZero(this.getHours()),
':',
addZero(this.getMinutes()),
':',
addZero(this.getSeconds()),
' ',
formatOffset(offset)
].join('');
},

@@ -166,5 +193,3 @@ toString: function toString() {

protoMethods.setDate = function setDate(a0) {
var localDate = getLocalDate(this);
nativeProto.setUTCDate.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(nativeProto.setUTCDate.apply(getLocalDate(this), arguments) - offsetInMilliseconds);
};

@@ -181,5 +206,3 @@ protoMethods.setUTCDate = nativeProto.setUTCDate;

protoMethods.setFullYear = function setFullYear(a0, a1, a2) {
var localDate = getLocalDate(this);
nativeProto.setUTCFullYear.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(nativeProto.setUTCFullYear.apply(getLocalDate(this), arguments) - offsetInMilliseconds);
};

@@ -192,5 +215,3 @@ protoMethods.setUTCFullYear = nativeProto.setUTCFullYear;

protoMethods.setHours = function setHours(a0, a1, a2, a3) {
var localDate = getLocalDate(this);
nativeProto.setUTCHours.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(nativeProto.setUTCHours.apply(getLocalDate(this), arguments) - offsetInMilliseconds);
};

@@ -203,5 +224,5 @@ protoMethods.setUTCHours = nativeProto.setUTCHours;

protoMethods.setMilliseconds = function setMilliseconds(a0) {
var localDate = getLocalDate(this);
nativeProto.setUTCMilliseconds.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(
nativeProto.setUTCMilliseconds.apply(getLocalDate(this), arguments) - offsetInMilliseconds
);
};

@@ -214,5 +235,3 @@ protoMethods.setUTCMilliseconds = nativeProto.setUTCMilliseconds;

protoMethods.setMinutes = function setMinutes(a0, a1, a2) {
var localDate = getLocalDate(this);
nativeProto.setUTCMinutes.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(nativeProto.setUTCMinutes.apply(getLocalDate(this), arguments) - offsetInMilliseconds);
};

@@ -225,5 +244,3 @@ protoMethods.setUTCMinutes = nativeProto.setUTCMinutes;

protoMethods.setMonth = function setMonth(a0, a1) {
var localDate = getLocalDate(this);
nativeProto.setUTCMonth.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(nativeProto.setUTCMonth.apply(getLocalDate(this), arguments) - offsetInMilliseconds);
};

@@ -236,9 +253,10 @@ protoMethods.setUTCMonth = nativeProto.setUTCMonth;

protoMethods.setSeconds = function setSeconds(a0, a1) {
var localDate = getLocalDate(this);
nativeProto.setUTCSeconds.apply(localDate, arguments);
return this.setTime(localDate.getTime() - offsetInMilliseconds);
return this.setTime(nativeProto.setUTCSeconds.apply(getLocalDate(this), arguments) - offsetInMilliseconds);
};
protoMethods.setUTCSeconds = nativeProto.setUTCSeconds;
var prototypePropertyDescriptors = makeMethodDescriptors(protoMethods);
if (typeof Symbol !== 'undefined') {
if (
// Symbol is undefined in Node 0.10.x
typeof Symbol !== 'undefined'
) {
if (Symbol.toStringTag) {

@@ -245,0 +263,0 @@ // Node v6+ or a polyfill

{
"name": "timezoned-date",
"version": "3.0.1",
"version": "3.0.2",
"license": "Apache-2.0",

@@ -31,3 +31,5 @@ "description": "Constructors and objects behave exactly like built-in Date; the TZ offset is configurable",

"eslint": "^3.8.0",
"if-node-version": "^1.1.1",
"mocha": "~3.2.0",
"prettier": "^1",
"sweet.js": "0.7.8",

@@ -37,3 +39,3 @@ "test262-harness": "^1.5.6"

"scripts": {
"lint": "eslint src/index.js --fix || true",
"lint": "if-node-version \">=4\" eslint src/index.js --fix",
"test": "npm run testown && npm run test262",

@@ -47,6 +49,10 @@ "pretestown": "babel test/es2015_native.js -o test/es2015_babel.js",

"native262": "test262-harness \"test262/test262/test/built-ins/Date/**/*.js\"",
"prepublish": "npm run lint && npm run build && npm test",
"prepublish": "npm run lint && npm run formatsrc && npm run build && npm run formatlib && npm test",
"prebuild": "test -d lib || mkdir lib",
"build": "sjs -r -m ./src/macros.js src/index.js > ./lib/index.js && babel lib/index.js -o lib/index.js"
"build": "npm run sweet && npm run babel",
"sweet": "sjs -r -m ./src/macros.js src/index.js > ./lib/index.js",
"babel": "babel lib/index.js -o lib/index.js",
"formatsrc": "if-node-version \">=4\" prettier --write --print-width 110 --tab-width 4 --single-quote src/index.js",
"formatlib": "if-node-version \">=4\" prettier --write --print-width 120 --tab-width 4 --single-quote lib/index.js"
}
}
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