Skip to content

Commit 92b08f5

Browse files
committed
update to new plugin functionality, do not export plug anymore but autoload plugin,
so users do not need to use `.use()` anymore, but just `import 'js-joda-locale''` Note: `Locale` can thus no longer be injected into `js-joda` ... so we need to extract it from the `js-joda-locale` import/require
1 parent 36656e9 commit 92b08f5

40 files changed

+334
-128
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
Changelog
22
=========
33

4-
### next (1.1.0)
4+
### next (2.0.0)
5+
6+
#### public API
7+
8+
introduced new plugin concept
9+
* Hide `use(plug)` concept from public api.
10+
The function for extending js-joda is not exported anymore (the default export of this module is removed).
11+
The code for extending js-joda `use(plug)` is not required anymore, because js-joda-timezone automaticaly extends
12+
js-joda when imported.
513

614
* get rid of postinstall build
715

dist/js-joda-locale.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! @version @js-joda/locale - 1.1.0-pre5+34.0.0
1+
//! @version @js-joda/locale - 2.0.0-pre5+34.0.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)
@@ -1516,18 +1516,26 @@ var WeekFieldsPrinterParser = function () {
15161516
/*!*******************************!*\
15171517
!*** ./src/js-joda-locale.js ***!
15181518
\*******************************/
1519-
/*! exports provided: default */
1519+
/*! exports provided: Locale */
15201520
/***/ (function(module, __webpack_exports__, __webpack_require__) {
15211521

15221522
"use strict";
15231523
__webpack_require__.r(__webpack_exports__);
1524-
/* harmony import */ var _plug__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./plug */ "./src/plug.js");
1524+
/* harmony import */ var js_joda__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! js-joda */ "js-joda");
1525+
/* harmony import */ var js_joda__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(js_joda__WEBPACK_IMPORTED_MODULE_0__);
1526+
/* harmony import */ var _plug__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./plug */ "./src/plug.js");
1527+
/* harmony import */ var _Locale__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Locale */ "./src/Locale.js");
1528+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Locale", function() { return _Locale__WEBPACK_IMPORTED_MODULE_2__["default"]; });
1529+
15251530
/*
15261531
* @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
15271532
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
15281533
*/
15291534

1530-
/* harmony default export */ __webpack_exports__["default"] = (_plug__WEBPACK_IMPORTED_MODULE_0__["default"]);
1535+
1536+
1537+
Object(js_joda__WEBPACK_IMPORTED_MODULE_0__["use"])(_plug__WEBPACK_IMPORTED_MODULE_1__["default"]);
1538+
15311539

15321540
/***/ }),
15331541

@@ -1542,16 +1550,14 @@ __webpack_require__.r(__webpack_exports__);
15421550
__webpack_require__.r(__webpack_exports__);
15431551
/* harmony import */ var _format_cldr_CldrDateTimeFormatterBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./format/cldr/CldrDateTimeFormatterBuilder */ "./src/format/cldr/CldrDateTimeFormatterBuilder.js");
15441552
/* harmony import */ var _format_LocaleDateTimeFormatter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./format/LocaleDateTimeFormatter */ "./src/format/LocaleDateTimeFormatter.js");
1545-
/* harmony import */ var _Locale__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Locale */ "./src/Locale.js");
1546-
/* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./_init */ "./src/_init.js");
1553+
/* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_init */ "./src/_init.js");
15471554
/*
15481555
* @copyright (c) 2017, Philipp Thuerwaechter & Pattrick Hueper
15491556
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
15501557
*/
15511558

15521559

15531560

1554-
15551561
/* harmony default export */ __webpack_exports__["default"] = (function (jsJoda) {
15561562
Object.getOwnPropertyNames(_format_cldr_CldrDateTimeFormatterBuilder__WEBPACK_IMPORTED_MODULE_0__["default"].prototype).forEach(function (prop) {
15571563
if (prop !== 'constructor') {
@@ -1563,7 +1569,6 @@ __webpack_require__.r(__webpack_exports__);
15631569
jsJoda.DateTimeFormatter.prototype[prop] = _format_LocaleDateTimeFormatter__WEBPACK_IMPORTED_MODULE_1__["default"].prototype[prop];
15641570
}
15651571
});
1566-
jsJoda.Locale = _Locale__WEBPACK_IMPORTED_MODULE_2__["default"];
15671572
});
15681573

15691574
/***/ }),

dist/js-joda-locale.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.

dist/js-joda-locale.min.js

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/usage_browser.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,19 @@
8282
let outputDateInDifferentLocales = function (zdt) {
8383
output('Times in ' + zdt.zone());
8484
output(' ');
85-
output('en_US formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.US)));
86-
output('en_CA formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.CANADA)));
87-
output('en_GB formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.UK)));
88-
output('de_DE formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.GERMANY)));
89-
output('fr_FR formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.FRANCE)));
90-
output('es_ES formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('es', 'ES ', 'es'))));
91-
output('ru_RU formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('ru', 'RU ', 'ru'))));
92-
output('zh_CN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('zh', 'CN ', 'zh'))));
93-
output('hi_IN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('hi', 'IN ', 'hi'))));
85+
output('en_US formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.US)));
86+
output('en_CA formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.CANADA)));
87+
output('en_GB formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.UK)));
88+
output('de_DE formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.GERMANY)));
89+
output('fr_FR formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.FRANCE)));
90+
output('es_ES formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('es', 'ES ', 'es'))));
91+
output('ru_RU formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('ru', 'RU ', 'ru'))));
92+
output('zh_CN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('zh', 'CN ', 'zh'))));
93+
output('hi_IN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('hi', 'IN ', 'hi'))));
9494
output(' ');
9595
output('<hr />');
9696
}
9797

98-
JSJoda = JSJoda.use(JSJodaTimezone).use(JSJodaLocale);
9998
var zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('Europe/Berlin'));
10099
outputDateInDifferentLocales(zdt)
101100
zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('America/Chicago'));

examples/usage_browser_build.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,19 @@
3939
function outputDateInDifferentLocales(zdt) {
4040
output('Times in ' + zdt.zone());
4141
output('&nbsp;');
42-
output('en_US formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.US)));
43-
output('en_CA formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.CANADA)));
44-
output('en_GB formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.UK)));
45-
output('de_DE formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.GERMANY)));
46-
output('fr_FR formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJoda.Locale.FRANCE)));
47-
output('es_ES formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('es', 'ES ', 'es'))));
48-
output('ru_RU formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('ru', 'RU ', 'ru'))));
49-
output('zh_CN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('zh', 'CN ', 'zh'))));
50-
output('hi_IN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJoda.Locale('hi', 'IN ', 'hi'))));
42+
output('en_US formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.US)));
43+
output('en_CA formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.CANADA)));
44+
output('en_GB formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.UK)));
45+
output('de_DE formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.GERMANY)));
46+
output('fr_FR formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(JSJodaLocale.Locale.FRANCE)));
47+
output('es_ES formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('es', 'ES ', 'es'))));
48+
output('ru_RU formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('ru', 'RU ', 'ru'))));
49+
output('zh_CN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('zh', 'CN ', 'zh'))));
50+
output('hi_IN formatted string: ' + zdt.format(JSJoda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new JSJodaLocale.Locale('hi', 'IN ', 'hi'))));
5151
output('&nbsp;');
5252
output('<hr />');
5353
}
5454

55-
JSJoda = JSJoda.use(JSJodaTimezone).use(JSJodaLocale);
5655
var zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('Europe/Berlin'));
5756
outputDateInDifferentLocales(zdt)
5857
zdt = JSJoda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, JSJoda.ZoneId.of('America/Chicago'));

examples/usage_es6.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
44
*/
55
/* eslint-disable no-console, no-var */
6-
import { use as jsJodaUse } from 'js-joda';
7-
import jsJodaTimeZone from 'js-joda-timezone';
8-
import jsJodaLocale from '../dist/js-joda-locale';
9-
10-
const { DateTimeFormatter, Locale, ZonedDateTime, ZoneId } = jsJodaUse(jsJodaTimeZone).use(jsJodaLocale);
6+
import { DateTimeFormatter, ZonedDateTime, ZoneId } from 'js-joda';
7+
import 'js-joda-timezone';
8+
import { Locale } from './build/js-joda-locale';
119

1210
const zdt = ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneId.of('Europe/Berlin'));
1311
// var zdt = joda.ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/Chicago'));

examples/usage_node.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
44
*/
55
/* eslint-disable no-console, no-var */
6-
const joda = require('js-joda')
7-
.use(require('js-joda-timezone'))
8-
.use(require('../dist/js-joda-locale'));
6+
const joda = require('js-joda');
7+
require('js-joda-timezone');
98

109
const {
1110
DateTimeFormatter,
1211
Instant,
13-
Locale,
1412
ZonedDateTime,
1513
ZoneId,
1614
} = joda;
1715

16+
const {
17+
Locale,
18+
} = require('./build/js-joda-locale');
19+
20+
1821
const zdt = ZonedDateTime.of(2016, 1, 1, 1, 2, 3, 4, ZoneId.of('Europe/Berlin'));
1922
const pattern = 'eeee MMMM dd yyyy GGGG, hh:mm:ss,nnnn a zzzz, \'Week \' ww, \'Quarter \' QQQ';
2023
const enUSFormatter = DateTimeFormatter.ofPattern(pattern).withLocale(Locale.US);

0 commit comments

Comments
 (0)