Back in 2018, there has been introduced new law in Poland to ban trading on sundays, but certain exceptions have been made (listed below). The task today is to determine, can one trade on the sunday provided by the user (according to these rules).
You can trade only if one of the following is satisfied:
- The day is the last sunday of 1st, 4th 6th and 8th month.
- The day is one of the two sundays preceding Christmas.
- The day is the sunday preceding Easter
Obviously one can't trade on certain holidays, but you can omit the check for them in your code. The only exclusion to this rule is Easter or Christmas (for obvious reasons).
For example, if the rules above allowed trading on 6th of January and albeit in reality you can't trade due to a holiday, you don't need to take that on the account (and assume that one can trade on 6th of January).
You can take the date in any reasonable format - "DDMMYYYY", "MMDDYYYY" and so on. The output should be a truthy or falsy value (answering the question - can you trade on this sunday?)
You can assume the input date to always be a sunday.
A few examples:
- You can trade on 27 January of 2019, due to rule 1.
- You can't trade on 13 January of 2019.
- You can't trade on 21 April of 2019 - it's Easter.
- You can trade on 14 April of 2019, due to rule 3.
- You can trade on 28 April of 2019, due to rule 1.
- You can trade on 15 December of 2019, due to rule 2.
- You can trade on 22 December of 2019, due to rule 2.
- You'll have to calculate the date of Easter and Christmas in the process.
- Your program has to work correctly with any other year than 2019.
- You MUST take on the account that you can't trade on Easter or Christmas, even if the conditions are satisfied.
- You don't need to check for other holidays.
The shortest code (in bytes) wins.