kodie / moment-holiday

A Moment.js plugin for handling holidays. NO LONGER MAINTAINED (DEPRECATED)
MIT License
83 stars 86 forks source link

modifyHolidays.set() only works on server side #22

Open martinshhh opened 6 years ago

martinshhh commented 6 years ago

On client side when I call moment.modifyHolidays.set('Canada') and then log it with moment().holidays() it returns the default locale (us). This only works server side. Is it possible to get it to work on client side?

daniel-varela commented 6 years ago

Well, this is weird. I have the exactly opposite issue. On my machine (running nodeJs version 8.10) I get running moment().modifyHolidays.set('Germany/RP') my desired holidays set. Though it doesn't seem to this on my server (an Azure function to be precise). Even though both are running a node Js server at the same version (8.10).

daniel-varela commented 6 years ago

The problem is a bug when using moment-holiday on windows. The failure of the set method occurs internally when calling the getLocale function. On Mac (like my dev laptop) and Linux (like your AWS server) this will not fail. Unfortunately due to the used backslashes in node for windows, this will fail since in this case the __dirname is not split at all.

Unfortunately no error is thrown since there is no catch block to catch an exception.... I'll create a pull request in the next hour in order to fix this.