TypeError: (intermediate value).resolvedOptions is not a function
Describe the bug When I call DateTime.fromJSDate on a native javascript Date, I get an error:
CONSOLE LOG: TypeError: (intermediate value).resolvedOptions is not a function
CONSOLE LOG: > at systemLocale (file: node_modules/luxon/src/impl/locale.js:46:0)
CONSOLE LOG: > at Function.create (file: node_modules/luxon/src/impl/locale.js:298:0)
CONSOLE LOG: > at Function.fromObject (file: node_modules/luxon/src/impl/locale.js:312:0)
CONSOLE LOG: > at Function.fromJSDate (file: node_modules/luxon/src/datetime.js:561:17)
To Reproduce
var date = new Date('10/1/2020');
console.log('date: ', date);
console.log('DateTime.fromJSDate(date): ', DateTime.fromJSDate(date));
Actual vs Expected behavior The expected behavior is that it would convert the native JS date into a Luxon DateTime object. Instead, it errors when calling DateTime.fromJSDate.
Desktop (please complete the following information):
- OS: macOS Big Sur 11.2.2
- Browser: None, this is a Angular + NativeScript mobile app running on an iOS simulator
- Luxon version: 1.26.0
Additional context Note that I also attempted to add locale support both with the node command line arguments as well as the full-icu npm package, however it had no impact. As it shouldn't, since Luxon is still supposed to work without locale support.
That's a weird one. It implies your environment (that simulator, I guess) has the Intl.DateTimeFormat API but it's missing the resolvedOptions() method, which is not something Luxon (or me, frankly) expects. We could work around this (return en-US if that method is missing), but I worry you'd just run into other problems elsewhere. Luxon guards against Intl being missing altogether and capability-checks the incremental Intl features that may or may not be there, but resolvedOptions() is not one of those; it's just a basic part of that API.
In theory I could fix this by finding everywhere that resolvedOptions is used and defining behavior for if it's not there. I'd rather not, though. It could also be that this environment is broken in other ways, and I don't want to play whack-a-mole. Perhaps there's something in the build toolchain that's not providing a complete implementation of that API?
I am running into the same issue! Also using Nativescript Angular on the iOS Simulator. Any solution to this?
I am running into the same issue! Also using Nativescript Angular on the iOS Simulator. Any solution to this?
same here but with luxon@2.. i guess there's still no solution for this