timezoned-date
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -11,3 +11,3 @@ 'use strict'; | ||
var _get = function get(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x2 = parent; _x3 = property; _x4 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
@@ -31,3 +31,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
// - so it can create objects with different offsets. | ||
var bound = typeof defaultOffset === 'number'; | ||
var bound = isOffset(defaultOffset); | ||
@@ -59,4 +59,4 @@ var TimezonedDate = (function (_OriginalDate) { | ||
_createClass(TimezonedDate, [{ | ||
key: 'localDate', | ||
value: function localDate() { | ||
key: '_localDate', | ||
value: function _localDate() { | ||
return applyOffset(this.date(), this.offset()); | ||
@@ -67,3 +67,3 @@ } | ||
value: function withOffset(offset) { | ||
return new TimezonedDate(this.getTime(), offset); | ||
return new ExportedTimezonedDate(this.getTime(), offset); | ||
} | ||
@@ -93,3 +93,3 @@ }, { | ||
value: function toString() { | ||
var localDate = this.localDate(), | ||
var localDate = this._localDate(), | ||
plusBrowserOffset = applyOffset(localDate, localDate.getTimezoneOffset()), | ||
@@ -102,3 +102,3 @@ asString = plusBrowserOffset.toString(); | ||
value: function getYear() { | ||
return this.localDate().getUTCFullYear() - 1900; | ||
return this._localDate().getUTCFullYear() - 1900; | ||
} | ||
@@ -133,3 +133,3 @@ }, { | ||
value: function value() { | ||
return this.localDate()['getUTC' + property](); | ||
return this._localDate()['getUTC' + property](); | ||
}, | ||
@@ -149,8 +149,10 @@ configurable: true, | ||
function addSetters(property) { | ||
var length = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; | ||
Object.defineProperty(TimezonedDate.prototype, 'set' + property, { | ||
value: function value(newValue) { | ||
var localDate = this.localDate(); | ||
localDate['setUTC' + property](newValue); | ||
value: fixLength(function () { | ||
var localDate = this._localDate(); | ||
localDate['setUTC' + property].apply(localDate, arguments); | ||
return this.setTime(applyOffset(localDate, -this.offset())); | ||
}, | ||
}, length), | ||
configurable: true, | ||
@@ -160,7 +162,7 @@ writable: true | ||
Object.defineProperty(TimezonedDate.prototype, 'setUTC' + property, { | ||
value: function value(newValue) { | ||
value: fixLength(function () { | ||
var date = this.date(); | ||
date['setUTC' + property](newValue); | ||
date['setUTC' + property].apply(date, arguments); | ||
return this.setTime(date); | ||
}, | ||
}, length), | ||
configurable: true, | ||
@@ -175,13 +177,13 @@ writable: true | ||
addGetters('FullYear'); | ||
addSetters('FullYear'); | ||
addSetters('FullYear', 3); | ||
addGetters('Hours'); | ||
addSetters('Hours'); | ||
addSetters('Hours', 4); | ||
addGetters('Milliseconds'); | ||
addSetters('Milliseconds'); | ||
addGetters('Minutes'); | ||
addSetters('Minutes'); | ||
addSetters('Minutes', 3); | ||
addGetters('Month'); | ||
addSetters('Month'); | ||
addSetters('Month', 2); | ||
addGetters('Seconds'); | ||
addSetters('Seconds'); | ||
addSetters('Seconds', 2); | ||
@@ -270,5 +272,13 @@ var _TimezonedDate = function _TimezonedDate(_a1, _a2, _a3, _a4, _a5, _a6, _a7) { | ||
var TimezonedDate = makeConstructor(false); | ||
TimezonedDate.makeConstructor = makeConstructor; | ||
exports['default'] = TimezonedDate; | ||
function fixLength(fn, length) { | ||
var argNames = []; | ||
for (var i = 0; i < length; i++) { | ||
argNames.push('_a' + i); | ||
} | ||
return eval('(function(' + argNames.join(',') + ') { return fn.apply(this, arguments); })'); | ||
} | ||
var ExportedTimezonedDate = makeConstructor(false); | ||
ExportedTimezonedDate.makeConstructor = makeConstructor; | ||
exports['default'] = ExportedTimezonedDate; | ||
module.exports = exports['default']; |
{ | ||
"name": "timezoned-date", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"license": "Apache-2.0", | ||
@@ -35,5 +35,5 @@ "description": "Work with timezone-aware dates", | ||
"test262native": "test262-harness \"test262/test262/test/built-ins/Date/**/*.js\"", | ||
"build": "babel --optional es7.classProperties,es7.decorators src --out-dir lib", | ||
"prepublish": "babel --optional es7.classProperties,es7.decorators src --out-dir lib", | ||
"watch": "babel --optional es7.classProperties,es7.decorators src --watch --out-dir lib" | ||
} | ||
} |
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
17575
242