Moved date/time function into a factory and fixed up some bugs with comments not being updated properly due to scope issues.