Skip to content

Commit dacc9e5

Browse files
committed
update README, fix examples, references to old js-joda-locale package
1 parent 63e6603 commit dacc9e5

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,52 +71,57 @@ Install joda using npm
7171
npm install @js-joda/locale
7272
```
7373

74-
To enable js-joda-locale you will onlye need to require it, requireing it automatically registers the locale extensions in the base `js-joda`
74+
To enable js-joda-locale you will only need to require it, requiring it automatically registers the locale extensions in the base `js-joda`
7575
Note: the `Locale` class is exported by `@js-joda/locale` so in order to use it, you will need to extract it from there.
7676

7777
```javascript
78-
require('js-joda-locale')
78+
require('@js-joda/locale_<locale>')
7979
```
8080
since `js-joda-locale` requires `js-joda-timezone` it will also need to be provided, as shown
8181
in the following examples
8282

83-
NOTE: if you are using a destructuring assignment in ES6, it should only be performed *after*
84-
the plugin `use`
85-
8683
### es5
8784

8885
```javascript
89-
const joda = require('js-joda');
90-
require('js-joda-timezone');
91-
9286
const {
9387
DateTimeFormatter,
9488
ZonedDateTime,
9589
ZoneId,
96-
} = joda;
90+
} = require('js-joda');
91+
require('js-joda-timezone');
9792

9893
const {
9994
Locale,
100-
} = require('js-joda-locale');
95+
} = require('@js-joda/locale_en-us');
10196

10297
var zdt = ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneId.of('Europe/Berlin'));
10398
console.log('en_US formatted string:', zdt.format(DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, \'Week \' ww, \'Quarter \' QQQ').withLocale(Locale.US)));
10499
```
100+
this will output `en_US formatted string: Friday January 01 2016 Anno Domini, 12:00:00 AM Central European Time, Week 01, Quarter Q1`
101+
105102
also see [examples/usage_node.js](examples/usage_node.js) or [examples/usage_node_build.js](examples/usage_node_build.js)
106103

107104
### es6
108105

109106
```ecmascript 6
110107
import { DateTimeFormatter, ZonedDateTime, ZoneId } from 'js-joda';
111108
import 'js-joda-timezone';
112-
import { Locale } from './build/js-joda-locale';
109+
import { Locale } from '.@js-joda/locale_en-us';
113110
114111
const zdt = ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, ZoneId.of('Europe/Berlin'));
115112
console.log('en_US formatted string:', zdt.format(DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, \'Week \' ww, \'Quarter \' QQQ').withLocale(Locale.US)));
116113
```
117114

118115
also see the [example](examples/usage_es6.js)
119116

117+
### using prebuilt locale files from core `@js-joda/locale`
118+
119+
If you prefer to download `@js-joda/locale` as a single dependency (albeit a rather large one in terms of download size), all prebuilt locale packages are also included.
120+
You still need to load the separate locale packages, this can be done e.g.
121+
```javascript
122+
require('@js-joda/locale/dist/prebuilt/en-us');
123+
```
124+
120125
### Browser
121126
- using requirejs to load
122127
- might also be possible with the bower version of cldr-data

0 commit comments

Comments
 (0)