How to use Luxon without import? #1453
Answered
by
diesieben07
GregJohnStewart
asked this question in
Q&A
-
I have a more 'basic' setup for including js files, and am having trouble bringing Luxon in. For sure a result of my patchwork understanding of JS. I am bringing in the scripts like: <script src="/lib/luxon/3.3.0/luxon.min.js"></script>
<script src="/res/js/timeHelpers.js"></script> TimeHelpers: (errs outlined in comments) import { DateTime, Settings, Info, Duration } from "../../lib/luxon/3.3.0/luxon.min"; //Fails as TimeHelpers isn't a module
const TimeHelpers = {
/**
* Get the current timestamp used for `datetime-local` inputs.
*/
getNowTs(){
return DateTime.now().toJSDate(); //can't find 'DateTime' without import
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
diesieben07
Jun 21, 2023
Replies: 1 comment 1 reply
-
If you're just working in the browser and load Luxon directly, its exports are visible through the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
GregJohnStewart
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you're just working in the browser and load Luxon directly, its exports are visible through the
luxon
global, as shown here in the documentation.Please let me know if this helps!