benjamin alexander smith

Sundial, Github and Open Source

Sundial is an international telephone number to timezone converter. Give it any telephone number qualified with the relevant international country code, or give it an unqualified US telephone number, and it will tell you the local time and timezone at the other end.

Sundial was first released in 2011 as a PHP hack to solve a common problem at work: “What’s the local time for this American guy I want to call?”

More recently I’ve added full support for international numbers. Again, I was just scratching my own itch: I’ve more frequently been calling clients all over the world. My timezone problem has been getting far worse.

This year, I rebuilt Sundial as a Sinatra application using Ruby and made it freely available as an open source project under the MIT licence on Github.

Now that I’m part of the open source community, what did I do when it came to add international support? Did I just go ahead and build all the functionality and gather all the relevant data myself? Hell no. I searched Github to see whether anybody else had already solved the problem.

It turns out that the answer was no. But several projects had produced libraries to parse international phone numbers, and one of them (phonie) had a Ruby gem that enabled me to easily pull out the international country code for any given telephone number. From there, I could use another Ruby gem, TZInfo, to get a local timezone and time.

Through the magic of open source, I could add support for international phone numbers to my app with very little effort. And better yet, it also gave me a chance to give back to the community.

A few guys at work started to use Sundial and quickly spotted that it didn’t support Mauritian or Korean telephone numbers. But thanks to the wonders of Github and the generousity of the guys who open sourced their parsing code, I could do something about it.

I spent half an hour researching Mauritian and Korean phone number formats, wrote a few tests, then wrote a little code. And now my contribution has added Mauritius and Korea telephone number support to phonie!

What goes around comes around. Only a day or two later, a kind soul raised an issue on Github to point out that Sundial would return 404 responses on particular inputs. I was able to add some new tests to cover the unexpected input, fix the issue quickly and easily, push the new code to Heroku, and voilĂ ! The world is a better place.

Releasing software to the community as an open source project is a great experience. Giving something back is fantastic, however small my contribution, and being able to participate in the back-and-forth of issues and pull requests has already been highly educational.

If you’ve got a project on your hard drive that might be of interested to even one other person, consider making it available to the world. And if you do, tweet me a link or drop me an email - I’d love to take a look.