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.0 to 3.0.1

34

lib/index.js

@@ -15,3 +15,3 @@ (function (root, factory) {

// 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*\(.+\))?$/,
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'],

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

date = new NativeDate(string + ' ' + formatOffset(offset));
if (! // TODO: can we use isInvalidDate here?
isNaN(date.getTime())) {
if (!isInvalidDate(date)) {
instance.setTime(date);
} else {
// It's some strange date/time string that nonetheless was successfully parsed to a
var // It's some strange date/time string that nonetheless was successfully parsed to a
// valid local native Date. Our last resort is to simply shift its offset, which
// however means that we can get a value off by 1 hour because of DST.
applyOffset(instance, -nativeProto.getTimezoneOffset.apply(instance) - offset);
time = instance.getTime() - nativeProto.getTimezoneOffset.apply(instance) * MILLISECONDS_PER_MINUTE - offsetInMilliseconds;
instance.setTime(time);
}

@@ -75,3 +75,3 @@ }

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

@@ -137,3 +137,3 @@ if (newTargetPrototype !== Object.prototype) {

getYear: function getYear() {
return getLocalDate(this).getUTCFullYear() - 1900;
return this.getFullYear() - 1900;
},

@@ -163,3 +163,3 @@ setYear: function setYear(year) {

nativeProto.setUTCDate.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -178,3 +178,3 @@ protoMethods.setUTCDate = nativeProto.setUTCDate;

nativeProto.setUTCFullYear.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -189,3 +189,3 @@ protoMethods.setUTCFullYear = nativeProto.setUTCFullYear;

nativeProto.setUTCHours.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -200,3 +200,3 @@ protoMethods.setUTCHours = nativeProto.setUTCHours;

nativeProto.setUTCMilliseconds.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -211,3 +211,3 @@ protoMethods.setUTCMilliseconds = nativeProto.setUTCMilliseconds;

nativeProto.setUTCMinutes.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -222,3 +222,3 @@ protoMethods.setUTCMinutes = nativeProto.setUTCMinutes;

nativeProto.setUTCMonth.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -233,3 +233,3 @@ protoMethods.setUTCMonth = nativeProto.setUTCMonth;

nativeProto.setUTCSeconds.apply(localDate, arguments);
return this.setTime(applyOffset(localDate, -offset));
return this.setTime(localDate.getTime() - offsetInMilliseconds);
};

@@ -253,6 +253,2 @@ protoMethods.setUTCSeconds = nativeProto.setUTCSeconds;

}
function applyOffset(date, offset) {
date.setTime(date.getTime() + MILLISECONDS_PER_MINUTE * offset);
return date;
}
function formatOffset(offset) {

@@ -300,3 +296,3 @@ var sign = offset >= 0 ? '+' : '-',

function isInvalidDate(date) {
var v = date.getDate();
var v = date.getTime();
return v !== v;

@@ -303,0 +299,0 @@ }

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

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

"test": "npm run testown && npm run test262",
"testown": "mocha --timeout 5000",
"pretestown": "babel test/es2015_native.js -o test/es2015_babel.js",
"testown": "mocha --timeout 5000 test/*_test.js",
"quicktest": "npm --quicktest=true run testown",
"pretest262": "find test262/test262 -maxdepth 0 || git clone https://github.com/tc39/test262.git test262/test262 --depth 1",
"pretest262": "test -d test262/test262 || git clone https://github.com/tc39/test262.git test262/test262 --depth 1",
"test262": "cat test262/prelude.prefix lib/index.js test262/prelude.suffix > test262/prelude.js && test262-harness --prelude test262/prelude.js \"test262/test262/test/built-ins/Date/**/*.js\"",

@@ -46,5 +47,5 @@ "prenative262": "npm run pretest262",

"prepublish": "npm run lint && npm run build && npm test",
"build": "mkdir lib 2>nul & sjs -r -m ./src/macros.js src/index.js > ./lib/index.js && babel lib/index.js --out-file lib/index.js",
"watch": "babel src/index.js --out-dir lib --watch"
"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"
}
}

@@ -46,2 +46,2 @@ # timezoned-date [![Build Status](https://travis-ci.org/thorn0/timezoned-date.svg?branch=master)](https://travis-ci.org/thorn0/timezoned-date) [![npm](https://img.shields.io/npm/v/timezoned-date.svg)](https://www.npmjs.com/package/timezoned-date)

Apache 2.0 © 2013-2017 James A. Rosen, Georgii Dolzhykov
[Apache 2.0](LICENSE) © 2013-2017 James A. Rosen, Georgii Dolzhykov
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