Time Keeps on Slippin'

Time may be infinite - but your work week and development resources aren’t.

In short sprints, it’s fairly easy to understand the impact of a one hour delay for a quick bugfix, or lost productivity due to a mid-week holiday. You don’t need a full featured project management suite either - just fire up a console window.

**David Bock’s Business Time** Ruby gem is a handy tool for traversing the calendar and doing math in terms of business hours & days. With a few short statements, you can forecast start & end dates and predict how potential delays will affect dependent activities.

```ruby require ‘active_support’ require ‘business_time’
today = Time.parse(“September 19th, 2013, 10:15 AM”)

Jump forward two business days

2.business_day.after(today) # 2013-09-23 10:15:00 -0400 – The following Monday

Jump back a few business hours

# 2013-09-18 13:15:00 -0400 – The previous afternoon

Define a non-standard work schedule

BusinessTime::Config.work_hours = {
# 2013-09-20 14:15:00 -0400

Start from the current time with .from_now and .ago

10.business_days.ago ```

Business Time can account for holidays, variable schedules, and way more. It’s a great resource for building time aware and schedule driven applications.

The only catch is that Business Time is only available in Ruby. Blerg. How will your PHP, Python, or Perl app make do without?

To borrow a phrase from Patrick Bateman, Don’t just stare at it, port it! This is an excellent opportunity to contribute to an open source project and cross-train your brain. Git started today!

Join the discussion

2017 Neal Shyam