docs/install.md
Luxon provides different builds for different JS environments. See below for a link to the right one and instructions on how to use it. Luxon supports all modern platforms, but see the support matrix for additional details.
You can also load the files from a CDN.
Just include Luxon in a script tag. You can access its various classes through the luxon global.
<script src="luxon.js"></script>
You may wish to alias the classes you use:
var DateTime = luxon.DateTime;
Supports Node.js 6+. Install via NPM:
npm install --save luxon
const { DateTime } = require("luxon");
If you want to work with locales, you need ICU support:
The instructions for using full-icu as a package are a little confusing. Node.js can't automatically discover that you've installed it, so you need to tell it where to find the data, like this:
npm install full-icu
node --icu-data-dir=./node_modules/full-icu
You can also point to the data with an environment var, like this:
NODE_ICU_DATA="$(pwd)/node_modules/full-icu" node
requirejs(["luxon"], function(luxon) {
//...
});
import { DateTime } from "luxon";
npm install --save luxon
import { DateTime } from "luxon";
There are third-party typing files for Flow (via flow-typed) and TypeScript (via DefinitelyTyped).
For Flow, use:
flow-typed install luxon
For TypeScript, use:
npm install --save-dev @types/luxon
React Native >=0.70 works just fine out of the box. Older versions of React Native for Android (or if you disable Hermes) doesn't include Intl support by default, which you need for a lot of Luxon's functionality.
For React Native >=0.60, you should configure the build flavor of jsc in android/app/build.gradle:
-def jscFlavor = 'org.webkit:android-jsc:+'
+def jscFlavor = 'org.webkit:android-jsc-intl:+'
For even older versions of React Native you can use jsc-android-buildscripts to fix it.