-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instructions.txt
30 lines (25 loc) · 2.04 KB
/
Instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--------------------------------------
Task One: Weekdays Between Two Dates
--------------------------------------
Calculates the number of weekdays in between two dates.
Weekdays are Monday, Tuesday, Wednesday, Thursday, Friday. The returned count should not include either firstDate or secondDate -
e.g. between Monday 07-Oct-2013 and Wednesday 09-Oct-2013 is one weekday. If secondDate is equal to or before firstDate, return 0.
-------------------------------------------
Task Two: Business Days Between Two Dates
-------------------------------------------
Calculates the number of business days in between two dates.
Business days are Monday, Tuesday, Wednesday, Thursday, Friday, but excluding any dates which appear in the supplied list of public holidays.
The returned count should not include either firstDate or secondDate - e.g. between Monday 07-Oct-2013 and Wednesday 09-Oct-2013 is one weekday.
If secondDate is equal to or before firstDate, return 0.
--------------------------------------
Task Three (Optional): More Holidays
--------------------------------------
For the hardcore coders that like a bit more of a design challenge. Bonus design question:
Design a data structure or hierarchy of structures which can define public holidays in a more complex fashion than simple dates.
This should cater for things such as:
- Public holidays which are always on the same day, e.g. Anzac Day on April 25th every year.
- Public holidays which are always on the same day, except when that falls on a weekend. e.g. New Year's Day on January 1st every year,
unless that is a Saturday or Sunday, in which case the holiday is the next Monday.
- Public holidays on a certain occurrence of a certain day in a month. e.g. Queen's Birthday on the second Monday in June every year.
Given this data structure, the BusinessDaysBetweenTwoDates() function should be able to be extended to take a list of public holiday rules,
rather than a list of DateTimes, and calculate the number of business days between two dates using those rules to define public holidays.