wlbr / feiertage

Gesetzliche Feiertage und mehr in Deutschland und Österreich (Bank holidays/public holidays in Austria and Germany)
MIT License
48 stars 7 forks source link

Sundays are showing, despite the variable "inklSonntage" being set to false #8

Closed ValentinMeincke closed 1 year ago

ValentinMeincke commented 1 year ago

If you add the test checkAndFailRegionFeiertageZahl(t, NordrheinWestfalen(2023,false),10) to the function func TestFeiertageZahl(t *testing.T) it fails. It seems that the variable "inklSonntage" for the Regions has no effect on actually including or excluding sundays. Example:

package main

import (
    "fmt"
    "github.com/wlbr/feiertage"
)

func main() {
    holidays := feiertage.NordrheinWestfalen(2023, true)
    count:=0
    for _, element := range holidays.Feiertage {
        count++
        fmt.Println(count, element.Time.Weekday().String(), element)
    }
}

Then the output will be:

1 Sunday 01.01.2023 Neujahr
2 Friday 07.04.2023 Karfreitag
3 Monday 10.04.2023 Ostermontag
4 Monday 01.05.2023 Tag der Arbeit
5 Thursday 18.05.2023 Christi Himmelfahrt
6 Monday 29.05.2023 Pfingstmontag
7 Thursday 08.06.2023 Fronleichnam
8 Tuesday 03.10.2023 Tag der deutschen Einheit
9 Wednesday 01.11.2023 Allerheiligen
10 Monday 25.12.2023 Weihnachten
11 Tuesday 26.12.2023 Zweiter Weihnachtsfeiertag

If we then change holidays := feiertage.NordrheinWestfalen(2023, true) to holidays := feiertage.NordrheinWestfalen(2023, false) we still get the same output which should not be. So the variable mentioned at the beginning seems to have no effect.

wlbr commented 1 year ago

I agree, the includingSundays "feature" is misleading. Root for this is, unfortunately, the individial laws of each Bundesland.

For example: by local law the list of "Feiertage" in Brandenburg is more or less what one would expect:

der Neujahrstag (1. Januar), der Karfreitag, der Ostersonntag, der Ostermontag, der 1. Mai (Tag der Arbeit), der Christi Himmelfahrtstag, der Pfingstsonntag, der Pfingstmontag, der Tag der deutschen Einheit (3. Oktober), das Reformationsfest (31. Oktober), der 1. Weihnachtsfeiertag (25. Dezember), der 2. Weihnachtsfeiertag (26. Dezember). https://bravors.brandenburg.de/gesetze/ftg_2015

but for Baden-Württemberg it is:

Neujahr, Erscheinungsfest (6. Januar), Karfreitag, Ostermontag, 1._Mai, Christi Himmelfahrt, Pfingstmontag, Fronleichnam, Allerheiligen (1. November), Erster Weihnachtstag, Zweiter Weihnachtstag https://www.landesrecht-bw.de/jportal/?quelle=jlink&query=FeiertG+BW&psml=bsbawueprod.psml&max=true&aiz=true

As you can see: Easter and Pentecost are no 'Feiertage' there.

Play around with:

go run cmd/feiertage/feiertage.go -region bb   2023
go run cmd/feiertage/feiertage.go -region bb --inklusiveSonntage  2023
go run cmd/feiertage/feiertage.go -region bw   2023
go run cmd/feiertage/feiertage.go -region bw --inklusiveSonntage  2023

This reflects the definition given by the laws on the Bundesland level. So one could say: -includingSundays is there to abstract from that somehow strange, individual definitions by each state. With its default setting it hides every Feiertag, that is a free day anyway, because it is a Sunday. In particular in Brandenburg it might be interested to know if a day is free because it is a Sunday or because it is a Feiertag - even it is a Sunday (maybe only in this year) - when you need to compensate work on this day. The rates might be higher on a Feiertag compared to a standard Sunday.

Today I did not check the definitions/laws for each state again, but it was correct when the library was written. Let me know if you find changes in den NRW law.