Workpattern Re-started

It’s no secret that I’ve always wanted to produce a piece of software that is generally available, and I’ve been trying to write a rubygem called Workpattern for some time. I have restarted it for what I hope is the fourth and final time. Workpattern will be a date calculation rubygem that takes into account patterns of working and resting time. The core Ruby classes that represent date and time allow calculations by adding a duration such as days or seconds to a date and returning the new #Date or #DateTime as the result.

Although there are 60 seconds in a minute, 60 minutes in an hour and 24 hours in (almost) every day, the working day is not that straight forward. Many working days are 8 hours a day, some are less at 7.5 hours a day. Sometimes there is a public holiday instead of a working day, and sometimes people work at nights or longer hours but less days per week. The Weekend, Public Holidays and Vacations are all days that are non working or resting days.

This Workpattern rubygem was born to allow date related calculations to take into account real life working and resting times. In essence it is told about resting and working periods and will add or subtract durations and dates as well as find out the duration between two dates. All durations are in minutes and all dates include hours and minutes.

A Short Illustration

In real life we may be reasonably confident that it will take us 32 hours to write a document. If we started on a Thursday at 9:00am we wouldn’t be working 32 hours without interruption (let’s pretend we’re not software developers for this one!). We’d go home at the end of one working day and not return until the next. We’d also not do anything on the weekend. We would probably work 8 hours on Thursday, Friday, Monday and Tuesday to complete the work.

The Workpattern rubygem will be able to tell you that if you started at 9:00 am on Thursday, you should be finished at 6:00 pm on Tuesday – you were allowed an hour for lunch each day! For it to do that it has to know when you work and when you rest.

Posted on 17 Aug 2011 by Barrie Callender
blog comments powered by Disqus