timezoned-date
Advanced tools
Comparing version 2.0.18 to 2.0.19
@@ -34,8 +34,14 @@ /*jshint esversion: 6, evil: true, -W103*/ | ||
} | ||
var args = Array.prototype.slice.call(arguments); | ||
var offset = bound ? boundOffset : args.pop(); | ||
var len = args.length; | ||
if (!isOffset(offset)) { | ||
throw new TypeError('TimezonedDate requires an offset'); | ||
var args, offset, len; | ||
if (bound) { | ||
args = arguments; | ||
offset = boundOffset; | ||
} else { | ||
args = Array.prototype.slice.call(arguments); | ||
offset = args.pop(); | ||
if (!isOffset(offset)) { | ||
throw new TypeError('TimezonedDate requires an offset'); | ||
} | ||
} | ||
len = args.length; | ||
var instance = len === 0 ? new NativeDate() : len === 1 ? new NativeDate(a0) : len === 2 ? new NativeDate(a0, a1) : len === 3 ? new NativeDate(a0, a1, a2) : len === 4 ? new NativeDate(a0, a1, a2, a3) : len === 5 ? new NativeDate(a0, a1, a2, a3, a4) : len === 6 ? new NativeDate(a0, a1, a2, a3, a4, a5) : new NativeDate(a0, a1, a2, a3, a4, a5, a6); | ||
@@ -120,8 +126,2 @@ setPrototypeOf(instance, proto); | ||
}, | ||
toUTCString: function toUTCString() { | ||
if (isNaN(this.getDate())) { | ||
return 'Invalid Date'; | ||
} | ||
return [daysOfWeek[this.getUTCDay()], ', ', addZero(this.getUTCDate()), ' ', months[this.getUTCMonth()], ' ', this.getUTCFullYear(), ' ', addZero(this.getUTCHours()), ':', addZero(this.getUTCMinutes()), ':', addZero(this.getUTCSeconds()), ' GMT'].join(''); | ||
}, | ||
getYear: function getYear() { | ||
@@ -134,10 +134,7 @@ return getLocalDate(this).getUTCFullYear() - 1900; | ||
// https://nodejs.org/api/util.html#util_custom_inspect_function_on_objects | ||
inspect: function inspect() { | ||
return this.toString(); | ||
}, | ||
getTime: nativeProto.getTime, | ||
setTime: nativeProto.setTime, | ||
valueOf: nativeProto.valueOf, | ||
toUTCString: nativeProto.toUTCString, | ||
toGMTString: nativeProto.toGMTString || nativeProto.toUTCString, | ||
toLocaleString: nativeProto.toLocaleString, | ||
@@ -152,5 +149,2 @@ toLocaleDateString: nativeProto.toLocaleDateString, | ||
protoMethods.setDate = function setDate(a0) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -170,5 +164,2 @@ nativeProto.setUTCDate.apply(localDate, arguments); | ||
protoMethods.setFullYear = function setFullYear(a0, a1, a2) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -184,5 +175,2 @@ nativeProto.setUTCFullYear.apply(localDate, arguments); | ||
protoMethods.setHours = function setHours(a0, a1, a2, a3) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -198,5 +186,2 @@ nativeProto.setUTCHours.apply(localDate, arguments); | ||
protoMethods.setMilliseconds = function setMilliseconds(a0) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -212,5 +197,2 @@ nativeProto.setUTCMilliseconds.apply(localDate, arguments); | ||
protoMethods.setMinutes = function setMinutes(a0, a1, a2) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -226,5 +208,2 @@ nativeProto.setUTCMinutes.apply(localDate, arguments); | ||
protoMethods.setMonth = function setMonth(a0, a1) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -240,5 +219,2 @@ nativeProto.setUTCMonth.apply(localDate, arguments); | ||
protoMethods.setSeconds = function setSeconds(a0, a1) { | ||
if (!(this instanceof constructor)) { | ||
throw new TypeError(); | ||
} | ||
var localDate = getLocalDate(this); | ||
@@ -279,3 +255,3 @@ nativeProto.setUTCSeconds.apply(localDate, arguments); | ||
function getLocalDate(date) { | ||
return applyOffset(new NativeDate(date), date.offset()); | ||
return new NativeDate(date.getTime() + MILLISECONDS_PER_MINUTE * date.offset()); | ||
} | ||
@@ -282,0 +258,0 @@ function formatOffset(offset) { |
{ | ||
"name": "timezoned-date", | ||
"version": "2.0.18", | ||
"version": "2.0.19", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "description": "Work with timezone-aware dates", |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
19280
0
174
4
288