Closed stonetwig closed 5 months ago
Instance here refers to the actual JavaScript object instance. What this means is that setting defaultLocale
will not affect any DateTime
instances that you have already created previously. For example:
Settings.defaultLocale = 'de';
const germanDate = DateTime.local();
Settings.defaultLocale = 'en';
const englishDate = DateTime.local();
console.log(germanDate.locale); // still 'de'
console.log(englishDate.locale); // still 'en'
Hello dear Luxon authors.
First and foremost, thanks for such a great library. You are doing great work.
I have a question regarding the defaultLocale.
On your website and api documentation you state:
Set the default locale to create DateTimes with. _Does not affect existing instances_.
I am a bit confused on the "does not affect existing instances" statement here. I have a web app where I change the default locale on each request like this:
I then use the exported variables here and call the init function on each request start with the user specific locale. On simultaneous requests, will this overwrite the defaultLocale setting or does this count as seperate existing instances? I never import the DateTime directly but I also do not create a new instance of it afaik.
Thanks in advance, stonetwig