[BusinessHoursUtils] Utility extension for Business Hours related operations

[BusinessHoursUtils] Utility extension for Business Hours related operations

  

Hey,

While implementing an application in OS10, I had the need to compute the business hours between two dates. After searching in Forge, I was unable to find any component to perform this task.

As such, I've decided to implement an extension to provide a function that computes the business hours between two given dates. 

I've also included some some configuration operations, here's a list of what is currently offered by this extension:


  • bool isHoliday(DateTime InputDateTime)

     Given a DateTime, returns whether it is an holiday.

  •  void setCountryCode(string CountryCode)

     Sets country code (used to retrieve the list of holidays).

  •   bool isWorkingday(DateTime InputDateTime)

     Given a DateTime, returns whether it is a working day.

  •   void setWorkingDays(bool Sunday, bool Monday, bool Tuesday, bool Wednesday, bool Thursday, bool Friday, bool Saturday)

     Sets the working days to be used by the extension. True means the weekday is a working day.

     Default working days are from Monday to Friday.

  •   void setWorkingHours(int BeginWorkingHour, int EndWorkingHour)  

     Sets the working hours to be used by the extension. Default values are 9 and 18, respectively.

     Note that this extension does not take into account lunch hour.

  •   int MssDiffWorkingHours(DateTime ssDateTime1, DateTime ssDateTime2)

      Gets the difference between two dates in working hours. No assumption is made over the given dates, they may be in any order.


This initial version does not take into account lunch hours (meaning it will be counted as a working hour) but it is in the backlog for a future version.

I hope you find this useful for your applications. Please feel free to give feedback for improvements as well as reports bugs you may find while using it.

Thanks!

Hi. Just one question: how is the coutrycode format and when i have to set it?

I've tried to set it (as "BE", without quotes) just before my action start, but i never saw a national holiday being returned.

Can you please help me.

Thanks in advance