Extracts the modified julian day method into a general function