Is there some library, pattern or common way deal with workdays? I mean, is there some relatively well adopted way to know if some day is a workday and not weekend, holiday etc.?
Also, supposing there is such thing, would it be helpful to discover if the day has some "detail"? For example, here in Brazil we use to work only in the afternoon of the Ash Wednesday. Is there some kind of flexible framework for dealing with such variations?
I could implement this kind of business logic without any difficulty but I would not like to reinvent the wheel and other users suggestions can be helpful. Also, it seems a very recurrent problem.
Thanks in advance!
We can use the WORKDAY function to know if a day is a workday or not. This function calculates defined “workdays” dates in the future or past. It automatically excludes weekend dates and (optionally), holidays.
=WORKDAY(start_date, days, [holidays]) The function uses the following arguments: Start_date (required function) – This is a date that represents the start date. Days (It is a required function) – The number of workdays to be added to start_date.
Microsoft Excel provides two functions specially designed for calculating weekdays - WORKDAY and NETWORKDAYS. The WORKDAY function returns a date N working days in the future or in the past and you can use it to add or subtract workdays to a given date.
If you are into Java programming you can use this : Non-working day and Holiday Handler Algorithms
Most people I know use a calendar table
for this kind of thing. My table contains info for 80+ countries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With