Refactoring/no manual date handling

Stop manipulating dates manually, use gmtime() for that.