refactored to remove duplicate code

while working on forcing UTC for dates I noticed we have a fair bit of duplicate code