checkdomain / Holiday

Check whether a date is a holiday
www.checkdomain.de
MIT License
49 stars 27 forks source link

Calculate correct easter date in BR provider #38

Closed hanzi closed 5 years ago

hanzi commented 5 years ago

The Brazil provider sometimes calculates the wrong Easter date for a given year.

It uses DateTimeImmutable::createFromFormat('U', easter_date($year)) -- which actually returns Saturday for timezones with a positive offset from UTC.

That's because easter_date() returns the UNIX timestamp for midnight on Easter Sunday, but for the current timezone. DateTimeImmutable::createFromFormat always uses UTC if a UNIX timestamp is provided, and for timezones with a positive offset midnight on Easter Sunday is actually Saturday afternoon or evening in UTC.

Accordingly, all Brazilian holidays relative to the Easter date are one day off under these circumstances.

This PR switches the Brazil provider to the AbstractEaster provider implementation which all the other providers are already using.

It also removes a duplicate: 'Carnaval' was defined both as a country-wide holiday and as a holiday for Rio de Janeiro state.

wandersonwhcr commented 5 years ago

I don't know why I didn't use the AbstractEaster class.

:+1:

wandersonwhcr commented 5 years ago

OK!