kodie / moment-holiday

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

broken? #24

Open rlayne opened 6 years ago

rlayne commented 6 years ago

I can't get any indication this plugin works with the latest or previous versions of moment.js. (I tried specifically using moment.js 2.0.0 as well as latest as of today).

Minimal case is:


<script src="js/moment.js"></script>
<script src="js/moment-holiday.js"></script>

<script>
var currentTime = moment();
console.log(currentTime); //Correct time shown

console.log('YOU: ' + currentTime.format("HH:mm DD-MM-YYYY")); //Correct time shown

var holiday = moment().isHoliday(null, true); //moment(...).isHoliday is not a function
</script>```
daniel-varela commented 6 years ago

As stated in the documentation:

If you're not using Node (or anything that doesn't support the require function), you'll need to make sure that you include the locale file(s) that you're trying to use.

<script src="./moment-holiday/locale/canada.js"></script>
<script src="./moment-holiday/locale/easter.js"></script>
<script>
  moment.modifyHolidays.set('Canada').add('Easter');
  moment('2001-12-26').isHoliday('Boxing Day');
  //true
</script>
rlayne commented 6 years ago

Oh, I'm sorry. I thought the minimal example provided under "browsers" would be sufficient. I should have read the entire document just in case something like that was randomly put in later.

Adding the additional locale file(s) doesn't change the outcome whatsoever.


<script src="js/moment.js"></script>
<script src="js/moment-holiday.js"></script>
<script src="js/united_kingdom.js"></script>
<script>
var currentTime = moment();
console.log(currentTime); //Correct time shown

console.log('YOU: ' + currentTime.format("HH:mm DD-MM-YYYY")); //Correct time shown

var holiday = moment().isHoliday(null, true); //moment(...).isHoliday is not a function
</script>```