DaniSchenk / moment-feiertage

MomentJS Plugin: Check if a date is a german holiday (Feiertag)
https://www.npmjs.com/package/moment-feiertage
32 stars 9 forks source link

Holidays are only recognized at 00:00 #11

Closed schwarmco closed 4 years ago

schwarmco commented 4 years ago

A holiday should be recognized on the whole day. The example snippet const nowIsHoliday = moment().isHoliday() in the README suggests, that this is also meant to be in the feature scope.

Example Code:

const moment = require('moment-feiertage')

console.log(moment('2020-12-25 17:00').isHoliday()) // false
console.log(moment('2020-12-25 00:00').isHoliday()) // 1. Weihnachtsfeiertag

A possible fix would probably be, to change https://github.com/DaniSchenk/moment-feiertage/blob/5f86fe50f87df87c31c0ff3e5e93de5b667a97ec/src/index.ts#L110 to

if (_moment.isSame(holidays[h].date, 'day')) { 
DaniSchenk commented 4 years ago

Damn! That's critical. Thank you for reporting back. I provided a fix and updated tests. Missed that in my Typescript rewrite...