inspired by: http://stackoverflow.com/questions/11337437/convert-object-to-daterange/11384801#11384801