Business Days Calculator

JavaScript
Hard

Objective

Write a JavaScript function to calculate the number of business days between two given dates.

Requirements

  1. The function should be called calculateBusinessDays

  2. The function should take two parameters:

    1. startDate - a string representing a date in the format "YYYY-MM-DD"

    2. endDate - a string representing a date in the format "YYYY-MM-DD"

  3. The function should return the number of business days between the two dates

    1. Inclusive of startDate but exclusive of endDate

  4. The function should consider weekends to be non-business days

  5. The following days should all be considered non-business days

    1. New Year's Day: January 1st, or the following Monday if it falls on a weekend.

    2. Good Friday: The Friday before Easter Sunday, which is the first Sunday following the full moon that appears on or after the March 21 equinox. For the purpose of this test you can consider Good Friday to be the 7th Apr or the Friday afterwards.

    3. Easter Monday: The day after Easter Sunday.

    4. Early May Bank Holiday: The first Monday in May.

    5. Spring Bank Holiday: The last Monday in May.

    6. Summer Bank Holiday: The last Monday in August.

    7. Christmas Day: December 25, or the following Monday if it falls on a weekend.

    8. Boxing Day: December 26, or the following Monday if it falls on a weekend.

  6. If the endDate is equal to or before the startDate the function should return 0

  7. You can ignore any extra bank holidays added for special occasions.