Skip to content

Commit 8ca80da

Browse files
committed
bump version
1 parent 08ecdba commit 8ca80da

File tree

5 files changed

+73
-87
lines changed

5 files changed

+73
-87
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
### 0.1.0
5+
6+
* add missing method in `Interval`
7+
* update eslint rules and adapt styling
8+
* replace all `var`s with `const`/`let`
9+
* update dependencies
10+
411
### 0.0.3
512

613
* add and use babel-plugin-add-module-exports to get rid of having to use `.default` when `.use`ing js-joda-extra

dist/js-joda-extra.js

Lines changed: 61 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
//! @version js-joda-extra - 0.0.3
1+
//! @version js-joda-extra - 0.1.0
22
//! @copyright (c) 2015-2016, Philipp Thürwächter, Pattrick Hüper & js-joda contributors
33
//! @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
44
//! @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5+
56
(function webpackUniversalModuleDefinition(root, factory) {
67
if(typeof exports === 'object' && typeof module === 'object')
78
module.exports = factory(require("js-joda"));
@@ -84,17 +85,17 @@ return /******/ (function(modules) { // webpackBootstrap
8485
exports.__esModule = true;
8586

8687
exports.default = function (jsJoda) {
87-
(0, _Interval._plugin)(jsJoda);
88+
jsJoda.Interval = _Interval.Interval;
8889
};
8990

9091
var _Interval = __webpack_require__(2);
9192

92-
/*
93-
* @copyright (c) 2016, Philipp Thuerwaechter & Pattrick Hueper
94-
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
95-
*/
93+
__webpack_require__(5);
9694

97-
module.exports = exports['default'];
95+
module.exports = exports['default']; /*
96+
* @copyright (c) 2016, Philipp Thuerwaechter & Pattrick Hueper
97+
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
98+
*/
9899

99100
/***/ },
100101
/* 2 */
@@ -105,15 +106,16 @@ return /******/ (function(modules) { // webpackBootstrap
105106
exports.__esModule = true;
106107
exports.Interval = undefined;
107108
exports._init = _init;
108-
exports._plugin = _plugin;
109109

110110
var _jsJoda = __webpack_require__(3);
111111

112112
var _assert = __webpack_require__(4);
113113

114-
var _errors = __webpack_require__(5);
115-
116-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
114+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /*
115+
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
116+
* @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
117+
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
118+
*/
117119

118120
var Interval = exports.Interval = function () {
119121
Interval.of = function of(startInstant, endInstantOrDuration) {
@@ -130,7 +132,7 @@ return /******/ (function(modules) { // webpackBootstrap
130132
(0, _assert.requireInstance)(startInclusive, _jsJoda.Instant, 'startInclusive');
131133
(0, _assert.requireInstance)(endExclusive, _jsJoda.Instant, 'endExclusive');
132134
if (endExclusive.isBefore(startInclusive)) {
133-
throw new _errors.DateTimeException('End instant must on or after start instant');
135+
throw new _jsJoda.DateTimeException('End instant must on or after start instant');
134136
}
135137
return new Interval(startInclusive, endExclusive);
136138
};
@@ -141,11 +143,40 @@ return /******/ (function(modules) { // webpackBootstrap
141143
(0, _assert.requireInstance)(startInclusive, _jsJoda.Instant, 'startInclusive');
142144
(0, _assert.requireInstance)(duration, _jsJoda.Duration, 'duration');
143145
if (duration.isNegative()) {
144-
throw new _errors.DateTimeException('Duration must not be zero or negative');
146+
throw new _jsJoda.DateTimeException('Duration must not be zero or negative');
145147
}
146148
return new Interval(startInclusive, startInclusive.plus(duration));
147149
};
148150

151+
Interval.parse = function parse(text) {
152+
(0, _assert.requireNonNull)(text, 'text');
153+
if (!(typeof text === 'string')) {
154+
throw new _jsJoda.IllegalArgumentException('text must be a string, but is ' + text.constructor.name);
155+
}
156+
for (var i = 0; i < text.length; i += 1) {
157+
if (text.charAt(i) === '/') {
158+
var firstChar = text.charAt(0);
159+
if (firstChar === 'P' || firstChar === 'p') {
160+
var duration = _jsJoda.Duration.parse(text.substring(0, i));
161+
var end = _jsJoda.ZonedDateTime.parse(text.substring(i + 1, text.length)).toInstant();
162+
return Interval.of(end.minus(duration), end);
163+
} else {
164+
var start = _jsJoda.ZonedDateTime.parse(text.substring(0, i)).toInstant();
165+
if (i + 1 < text.length) {
166+
var c = text.charAt(i + 1);
167+
if (c === 'P' || c === 'p') {
168+
var _duration = _jsJoda.Duration.parse(text.substring(i + 1, text.length));
169+
return Interval.of(start, start.plus(_duration));
170+
}
171+
}
172+
var _end = _jsJoda.ZonedDateTime.parse(text.substring(i + 1, text.length)).toInstant();
173+
return Interval.of(start, _end);
174+
}
175+
}
176+
}
177+
throw new _jsJoda.DateTimeParseException('Interval cannot be parsed, no forward slash found', text, 0);
178+
};
179+
149180
function Interval(startInclusive, endExclusive) {
150181
_classCallCheck(this, Interval);
151182

@@ -215,7 +246,7 @@ return /******/ (function(modules) { // webpackBootstrap
215246
(0, _assert.requireNonNull)(other, 'other');
216247
(0, _assert.requireInstance)(other, Interval, 'other');
217248
if (this.isConnected(other) === false) {
218-
throw new _errors.DateTimeException('Intervals do not connect: ' + this + ' and ' + other);
249+
throw new _jsJoda.DateTimeException('Intervals do not connect: ' + this + ' and ' + other);
219250
}
220251
var cmpStart = this._start.compareTo(other.start());
221252
var cmpEnd = this._end.compareTo(other.end());
@@ -234,7 +265,7 @@ return /******/ (function(modules) { // webpackBootstrap
234265
(0, _assert.requireNonNull)(other, 'other');
235266
(0, _assert.requireInstance)(other, Interval, 'other');
236267
if (this.isConnected(other) === false) {
237-
throw new _errors.DateTimeException('Intervals do not connect: ' + this + ' and ' + other);
268+
throw new _jsJoda.DateTimeException('Intervals do not connect: ' + this + ' and ' + other);
238269
}
239270
var cmpStart = this._start.compareTo(other.start());
240271
var cmpEnd = this._end.compareTo(other.end());
@@ -316,19 +347,8 @@ return /******/ (function(modules) { // webpackBootstrap
316347
return Interval;
317348
}();
318349

319-
var _initialized = false;
320-
321350
function _init() {
322-
323351
Interval.ALL = Interval.of(_jsJoda.Instant.MIN, _jsJoda.Instant.MAX);
324-
_initialized = true;
325-
}
326-
327-
function _plugin(jsJoda) {
328-
if (!_initialized) {
329-
_init();
330-
}
331-
jsJoda.Interval = Interval;
332352
}
333353

334354
/***/ },
@@ -349,7 +369,7 @@ return /******/ (function(modules) { // webpackBootstrap
349369
exports.requireInstance = requireInstance;
350370
exports.abstractMethodFail = abstractMethodFail;
351371

352-
var _errors = __webpack_require__(5);
372+
var _jsJoda = __webpack_require__(3);
353373

354374
function assert(assertion, msg, error) {
355375
if (!assertion) {
@@ -365,14 +385,14 @@ return /******/ (function(modules) { // webpackBootstrap
365385
*/
366386
function requireNonNull(value, parameterName) {
367387
if (value == null) {
368-
throw new _errors.NullPointerException(parameterName + ' must not be null');
388+
throw new _jsJoda.NullPointerException(parameterName + ' must not be null');
369389
}
370390
return value;
371391
}
372392

373393
function requireInstance(value, _class, parameterName) {
374394
if (!(value instanceof _class)) {
375-
throw new _errors.IllegalArgumentException(parameterName + ' must be an instance of ' + (_class.name ? _class.name : _class) + (value && value.constructor && value.constructor.name ? ', but is ' + value.constructor.name : ''));
395+
throw new _jsJoda.IllegalArgumentException(parameterName + ' must be an instance of ' + (_class.name ? _class.name : _class) + (value && value.constructor && value.constructor.name ? ', but is ' + value.constructor.name : ''));
376396
}
377397
return value;
378398
}
@@ -383,70 +403,28 @@ return /******/ (function(modules) { // webpackBootstrap
383403

384404
/***/ },
385405
/* 5 */
386-
/***/ function(module, exports) {
406+
/***/ function(module, exports, __webpack_require__) {
387407

388408
'use strict';
389409

390-
exports.__esModule = true;
391-
/**
392-
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
393-
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
394-
*/
410+
var _Interval = __webpack_require__(2);
395411

396-
function createErrorType(name, init) {
397-
var superErrorClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Error;
412+
var isInit = false; /*
413+
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
414+
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
415+
*/
398416

399-
function E(message) {
400-
if (!Error.captureStackTrace) {
401-
this.stack = new Error().stack;
402-
} else {
403-
Error.captureStackTrace(this, this.constructor);
404-
}
405-
this.message = message;
406-
init && init.apply(this, arguments);
417+
function init() {
418+
if (isInit) {
419+
return;
407420
}
408-
E.prototype = new superErrorClass();
409-
E.prototype.name = name;
410-
E.prototype.constructor = E;
411-
return E;
412-
}
413-
414-
var DateTimeException = exports.DateTimeException = createErrorType('DateTimeException', messageWithCause);
415-
var DateTimeParseException = exports.DateTimeParseException = createErrorType('DateTimeParseException', messageForDateTimeParseException);
416-
var UnsupportedTemporalTypeException = exports.UnsupportedTemporalTypeException = createErrorType('UnsupportedTemporalTypeException', null, DateTimeException);
417-
var ArithmeticException = exports.ArithmeticException = createErrorType('ArithmeticException');
418-
var IllegalArgumentException = exports.IllegalArgumentException = createErrorType('IllegalArgumentException');
419-
var IllegalStateException = exports.IllegalStateException = createErrorType('IllegalStateException');
420-
var NullPointerException = exports.NullPointerException = createErrorType('NullPointerException');
421421

422-
function messageWithCause(message) {
423-
var cause = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
422+
isInit = true;
424423

425-
var msg = message || this.name;
426-
if (cause !== null && cause instanceof Error) {
427-
msg += '\n-------\nCaused by: ' + cause.stack + '\n-------\n';
428-
}
429-
this.message = msg;
424+
(0, _Interval._init)();
430425
}
431426

432-
function messageForDateTimeParseException(message) {
433-
var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
434-
var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
435-
var cause = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
436-
437-
var msg = message || this.name;
438-
msg += ': ' + text + ', at index: ' + index;
439-
if (cause !== null && cause instanceof Error) {
440-
msg += '\n-------\nCaused by: ' + cause.stack + '\n-------\n';
441-
}
442-
this.message = msg;
443-
this.parsedString = function () {
444-
return text;
445-
};
446-
this.errorIndex = function () {
447-
return index;
448-
};
449-
}
427+
init();
450428

451429
/***/ }
452430
/******/ ])

dist/js-joda-extra.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)