Porting over the bits I need from date.js (http://www.datejs.com/)